Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

having issues casting timestamp to date

malkyJan 11 2013 — edited Jan 11 2013
Hi there,

So here's what I have.. I have a timestamp in my database and i need to return it as a date (because what used to work in WL8.1 now is giving me a java.lang.IllegalArgumentException: Cannot convert this to java.sql.Date in WL10). So i'm changing my query as follows:

I do run my old query to get a sample:
select col_key, col_time, col_other
from table1 where col_key = 'a'

... and i get for col_time *'01/11/2013 1:18:04.354261 PM'* ... so far so good.

So i grab that value and I do the following to test my format:

select CAST(to_timestamp('01/11/2013 1:18:04.354261 PM', 'MM/DD/YYYY HH:MI:SS.ff PM') AS DATE) from dual;
works perfect, returns the date: 01/11/2013 1:18:04 PM


Given the above I apply that to my old query now:
select col_key, CAST(to_timestamp(col_time, 'MM/DD/YYYY hh:mi:ss.ff PM') AS DATE), col_other
from table1 where col_key = 'a'

and I get a "ORA-01858: a non-numeric character was found where a numeric was expected"

... where did I go wrong?

Thanks
This post has been answered by JohnWatson on Jan 11 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 8 2013
Added on Jan 11 2013
7 comments
1,182 views