I’m working with some data in an Oracle 10g database, specifically bulk updating and reading timestamp information. I had to convert from an MM/DD/YYYY HH24:MI:SS format to a YYYY-MM-DD HH24:MI:SS format because of business requirements. As well, the timestamp is stored as a VARCHAR instead of a native datetime due to business requirements.
Unfortunately, now I’m having trouble running select operations on my data.
Specifically, when I run the following select I receive ORA-01861: Literal does not match format string:
SELECT datetime_stamp
from entrytable
where
to_date(datetime_stamp, 'YYYY-MM-DD HH24:MI:SS')
between
TO_DATE('11/27/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS')
and
TO_DATE('12/06/2011 23:59:59', 'MM/DD/YYYY HH24:MI:SS')
and rownum < 1000
I confirmed that the bad argument is to_date(datetime_stamp, ‘YYYY-MM-DD HH24:MI:SS’), but now I have 400k rows of data to parse to try and find the bad row.
Is there any way I can have Oracle return the row that is generating the ORA-01861 error?
I’ve tried using REGEXP_LIKE to find data that does not fit [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9], but all rows seem to fit that regular expression.
and then