# Oracle Adapter with DateTime conversion not working

**URL:** <https://www.ruby-forum.com/t/oracle-adapter-with-datetime-conversion-not-working/134701>\
**Category:** Rails\
**Created:** [April 14, 2008, 9:25am UTC](https://www.ruby-forum.com/t/oracle-adapter-with-datetime-conversion-not-working/134701 "2008-04-14T09:25:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexmic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@alexmic](https://www.ruby-forum.com/u/alexmic)\
**Post date:** [April 14, 2008, 9:25am UTC](https://www.ruby-forum.com/t/oracle-adapter-with-datetime-conversion-not-working/134701/1 "2008-04-14T09:25:53Z")

</div>

I’m trying to find all people that we’re created at a specific date and  
time, however rails does not seem to be performing the correct  
conversion into oracle’s format. Should this work by default? I can  
fix it by wrapping in a date function, but I thought this was something  
that should be handled by the adapater.

Person.find\_all\_by\_created\_at(DateTime.parse(params[:created\_at]))

#The query it generates  
SELECT \*  
FROM people  
WHERE created\_at = ‘2008-04-15 12:00:00’

#The Oracle Error  
SQL Error: ORA-01861: literal does not match format string  
01861. 00000 - “literal does not match format string”  
\*Cause: Literals in the input must be the same length as literals in  
the format string (with the exception of leading whitespace).  
If the  
“FX” modifier has been toggled on, the literal must match  
exactly,  
with no extra whitespace.  
\*Action: Correct the format string to match the litera

---

<div class="post-metadata">

**Author:** ![alexmic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@alexmic](https://www.ruby-forum.com/u/alexmic)\
**Post date:** [April 21, 2008, 10:58am UTC](https://www.ruby-forum.com/t/oracle-adapter-with-datetime-conversion-not-working/134701/2 "2008-04-21T10:58:47Z")

</div>

Hi,

This is not due to the Oracle Adapter.  
You need to write the SQL like this:

> SELECT \*  
> FROM people  
> WHERE created\_at = to\_date(‘2008-04-15 12:00:00’, ‘YYYY-MM-dd HH-MI-SS’)

–  
Cheers,  
Jesse

2008/4/14, Alex M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
