As we all know, when using TO_DATE, you need to make sure that your literal string matches the format mask, otherwise you get an error.
For example
SQL> select to_date('01/01/2000') from dual;
select to_date('01/01/2000') from dual
*
ERROR at line 1:
ORA-01843: not a valid month
SQL> select to_date('January 1st 2020','DD-MON-YY') from dual;
select to_date('January 1st 2020','DD-MON-YY') from dual
*
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected
So naturally, you would expect all of the following attempts to use TO_DATE to fail
select to_date('01JAN2000','ddmmyyyy') from dual;
select to_date('01JAN1999','ddmmyyyy') from dual;
select to_date('01JAN2000','dd/mm/yy') from dual;
select to_date('01JAN2000','dd-mm-yyyy') from dual;
But take a look at this
SQL> select to_date('01JAN2000','ddmmyyyy') from dual;
TO_DATE('
---------
01-JAN-00
SQL> select to_date('01JAN1999','ddmmyyyy') from dual;
TO_DATE('
---------
01-JAN-99
SQL> select to_date('01JAN2000','dd/mm/yy') from dual;
TO_DATE('
---------
01-JAN-00
SQL> select to_date('01JAN2000','dd-mm-yyyy') from dual;
TO_DATE('
---------
01-JAN-00
What tomfoolery is going on here? Well, because it is Christmas this is just another example of how nice we are at Oracle 😃
When you get “close” to being correct, we will go the extra mile to try help you out. As per the docs:
There’s a better way of doing this with dates … but you’ll need to wait until tomorrow for that one.
Ho Ho Ho! Merry Christmas.




Got some thoughts? Leave a comment