Oracle Date + RoR

Hi Experts,

I’ve a model called Product where i’ve column called created_at,
updated_at

where i’ve made a query based on Oracle date format

like

date_of_created = ‘23-SEP-07’
@product = Product.find(:all, :conditions => [“created_at=?”,
date_of_created])

but in view its empty.

AND EXPERTS I’VE DATA WITH 24-SEP-07 FOR MORE THAN 10 RECORDS, AND
I’VE MINOR DOUBT BASED ON STRUCTURE OF A TABLE I MEANT THE TYPE OF
CREATED_AT COLUMN, LIKE WHEN I DO MIGRATE I MADE CREATED_AT as
datetime, but oracle supports date type, is there any difference?

regards,

Bala

Yes, the oracle date column doesn’t contain time. Im not to sure about
this
but try adding .to_time to your date_of_created

@product = Product.find(:all, :conditions => [“created_at=?”,
date_of_created.to_time])

I would definitely keep it datetime. Read up about oracle date column.
There
are some funnies involved. I have never used oracle so not clued up.

The issue here I believe is that the created_at field is datetime which
contains date elements and time elements. the "23-Sept-07’ string
doesn’t
compare well. When you call .to_time in converts that string into a
datetime object. This can then be nicely compared with the datetime
field. I
would rather change the way I do the query by always passing a datetime
than
change the database and work with strings.

regards
ivor

Thanks Paul, it works well.

but anyway is it good solution if i use created_at type as varchar to
query?

or it’ll be a probs?