I have a table1(DueDate varchar2(20)). It has thousands of date data in different format with some bad data like characters.
eg.
YYYYMMDD,
MM/DD/YYYY,
MM-DD-YYYY,
M/D/YYYY,
'ABCD'
YYYYMMD,
YYYYMDD,
Now I had to get the dates that are past one week overdue. How do I do that?
Thank you for your help.
This is one of the reasons that storing date information in a character field is such a bad idea.
The easiest option is to create a function that attempts to convert the string to a date using the formats in whatever priority order you have (i.e. is 010203 Jan 2, 2003 or Feb 3, 2001 or something else) and catches the exceptions. Something like
which works something like
Of course, you’d have to code the full set of valid date formats in your code, I’m just handling the first two in your list.