When Oracle implicitly converts from a DATE
to a string or vice-versa (or when TO_CHAR()
or TO_DATE()
are explicitly called without a format model) the NLS_DATE_FORMAT
session parameter will be used as the format model in the conversion. If the literal does not match the format model then an exception will be raised.
You can review this parameter using:
SELECT VALUE FROM NLS_SESSION_PARAMETERS WHERE PARAMETER = 'NLS_DATE_FORMAT';
You can set this value within your current session using:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
(Note: this does not change the value for any other users.)
If you rely on the NLS_DATE_FORMAT
to provide the format mask in TO_DATE()
or TO_CHAR()
then you should not be surprised when your queries break if this value is ever changed.