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!

Date conversion in where clause

1102964May 31 2016 — edited Jun 3 2016

I have 2 input fields as string from_date and to_date which is in format 'MM-dd-yyyy HH:mm:ss'. I have a table column reported_date which is again string and in format 'yyyy-mm-dd hh24:mi:ss'.

I tried

to_char(to_timestamp('01-01-2011 13:43:31','MM-dd-yyyy HH:mm:ss'),'yyyy-mm-dd hh24:mi:ss') as FROM_TIME, to_char(to_timestamp('30-05-2016 13:43:31','MM-dd-yyyy HH:mm:ss'),'yyyy-mm-dd hh24:mi:ss') as TO_TIME

and then "where to_timestamp(reported_date,'yyyy-mm-dd hh24:mi:ss') between to_timestamp(FROM_DATE, 'yyyy-mm-dd hh24:mi:ss') and to_timestamp(TO_DATE,''yyyy-mm-dd hh24:mi:ss')

im getting this error "format code appears twice"

I need a select query where reported_date between from_date and to_date.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 1 2016
Added on May 31 2016
10 comments
3,766 views