If you use to_date
that way, you're relying on the language of your environment.
If you use 'Jan'
you're assuming that you're using a language where January may be written as 'Jan'
, so you may need to explicitly set the language to use to interpret the dates.
For example, say my language is Italian, so that 'January' is written as 'Gen' and not 'Jan'; if a try your query, I get the same error:
SQL> SELECT to_date ('12-Jan-2017 12:04', 'DD-MON-YYYY HH24:MI') AS DATET
2 FROM DUAL;
SELECT to_date ('12-Jan-2017 12:04', 'DD-MON-YYYY HH24:MI') AS DATET
*
ERROR at line 1:
ORA-01843: not a valid month
If I explicitly say the language to use to interpret the stored dates, I have:
SQL> SELECT to_date ('12-Jan-2017 12:04', 'DD-MON-YYYY HH24:MI', 'NLS_DATE_LANGUAGE = English') AS DATET
2 FROM DUAL;
DATET
---------
12-GEN-17