# Oracle Date + RoR

**URL:** <https://www.ruby-forum.com/t/oracle-date-ror/115351>\
**Category:** Rails\
**Created:** [September 24, 2007, 9:29am UTC](https://www.ruby-forum.com/t/oracle-date-ror/115351 "2007-09-24T09:29:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bala](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@Bala](https://www.ruby-forum.com/u/Bala)\
**Post date:** [September 24, 2007, 9:29am UTC](https://www.ruby-forum.com/t/oracle-date-ror/115351/1 "2007-09-24T09:29:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bala](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@Bala](https://www.ruby-forum.com/u/Bala)\
**Post date:** [September 24, 2007, 9:50am UTC](https://www.ruby-forum.com/t/oracle-date-ror/115351/2 "2007-09-24T09:50:04Z")

</div>

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])

---

<div class="post-metadata">

**Author:** ![Bala](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@Bala](https://www.ruby-forum.com/u/Bala)\
**Post date:** [September 24, 2007, 10:39am UTC](https://www.ruby-forum.com/t/oracle-date-ror/115351/3 "2007-09-24T10:39:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bala](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@Bala](https://www.ruby-forum.com/u/Bala)\
**Post date:** [September 24, 2007, 10:25am UTC](https://www.ruby-forum.com/t/oracle-date-ror/115351/4 "2007-09-24T10:25:08Z")

</div>

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?
