Not really a Ruby question, but

Hello,
I’m using a Ruby script to grab some data from an Oracle database via
an ODBC connection. Everything works great, but I want to select a
certain date range when I query the database. However, the date is in a
different format, I think. The Oracle field type is “date”. How would I
be able to format a date like 05/20/2008 so that I can compare it with
the date field in Oracle?

Thanks,

  • Jeff M.

Maybe Time.now.strftime(’%d/%m/%Y’)

by
TheR

2008/5/28 Jeff M. [email protected]:

Hello,
I’m using a Ruby script to grab some data from an Oracle database via
an ODBC connection. Everything works great, but I want to select a
certain date range when I query the database. However, the date is in a
different format, I think. The Oracle field type is “date”. How would I
be able to format a date like 05/20/2008 so that I can compare it with
the date field in Oracle?

select …
from …
where your_date >= TO_DATE(‘05/20/2008’, ‘MM/DD/YYYY’)
and …

see
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions183.htm#i1003589

Note, a good place to look for Oracle docs is http://tahiti.oracle.com

Cheers

robert