Problems with date condition in SQL statement
682228Jan 28 2009 — edited Jan 29 2009Hi,
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.