Best practice
Sergiusz Wolicki, March 12, 2025 - 11:38 pm UTC
The best practice is to use DATE literals:
select date '2025-10-03' from dual;
This makes the date specification independent from both NLS_DATE_FORMAT and NLS_CALENDAR, and it is a much shorter notation.
The problem with the DATE literals is that they do not support the time part. If you want to specify the time part, you need something like:
select cast(timestamp '2025-10-03 23:55:37' as date) from dual;
The cast is especially important if such a specification is included in a predicate when it is compared to an indexed DATE column. TIMESTAMP has higher priority than DATE in implicit conversions, so if the explicit cast is missing, the column's data type is converted to TIMESTAMP, making index range access impossible.
March 13, 2025 - 1:50 pm UTC
Thanks for sharing Sergiusz.