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!

Problems with date condition in SQL statement

682228Jan 28 2009 — edited Jan 29 2009
Hi,

I have an error while running below sql.

I have this snap_id column which datatype is VARCHAR. Sample record is like 200901280000
which the first eight character refer to a date. I want to take this as a condition in my SQL to look for the dates that are more than or equal to certain specified date like below.

But I get error code ORA-01722 when running it in SqlDeveloper.
and substr(snap_id,1,8) >= to_char('28-JAN-2009','yyyymmdd')

I also try below and get error code ORA-01858.
and to_date(substr(snap_id,1,8),'yyyymmdd') >= to_date('28-JAN-2009','yyyymmdd')

Pls help to show me what is the correct format should I use to the above condition. Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2009
Added on Jan 28 2009
8 comments
1,320 views