In the life of a developer, keystrokes matter, and “he/she who dies with the least keystrokes wins”.😃
So it can be frustrating when every time you want to enter a date and you want to make sure you are not beholden to the whim of the session NLS settings , then you need to specify
- The TO_DATE function, and
- Your date literal, and
- The format mask
I just wanted a damn date and here I am typing in:
SQL> select to_date('25-DEC-2024','DD-MON-YYYY') from dual;
TO_DATE('
---------
25-DEC-24
But there is an easier way, one I’ve been using for as long as I remember. As long as you adopt the ISO standard (Please don’t ask me what particular ISO number it is, it’s just the “ISO standard” OK? 😃) then you can construct dates and timestamps much more easily
SQL> select date '2024-12-25' from dual;
DATE'2024
---------
25-DEC-24
SQL> select timestamp '2024-12-25 13:00:00' from dual;
TIMESTAMP'2024-12-2513:00:00'
----------------------------------------------------------------
25-DEC-24 01.00.00.000000000 PM
Ho Ho Ho… Merry Christmas!




Leave a reply to aminaa49ed2e27e Cancel reply