Oracle’s DATE datatype stores both the
calendar date and
time-of-day down to the second.
Although the default display format in most Oracle environments is still influenced by the
NLS_DATE_FORMAT parameter, the underlying DATE value always contains:
- Year
- Month
- Day
- Hour
- Minute
- Second
Oracle 23c continues to support a rich family of date-manipulation functions. These functions allow developers to add or subtract intervals, convert dates to character strings, and compute differences between dates.
The most commonly used date functions include:
| Function |
Syntax |
Description |
ADD_MONTHS |
ADD_MONTHS(col1, n) |
Adds n months to a date. |
LAST_DAY |
LAST_DAY(col1) |
Returns the last day of the month for the given date. |
MONTHS_BETWEEN |
MONTHS_BETWEEN(col1, col2) |
Computes the number of months between two dates, returning fractional values where applicable. |
NEW_TIME |
NEW_TIME(col1, zone1, zone2) |
Converts a date from one time zone to another. (Still supported in Oracle 23c.) |
NEXT_DAY |
NEXT_DAY(col1, day) |
Returns the next occurrence of the specified weekday. |
ROUND |
ROUND(col1, round_to) |
Rounds a date to the nearest unit (day, month, year, etc.). |
TRUNC |
TRUNC(col1, trunc_to) |
Truncates a date to a specified unit (day, month, year, etc.). |
TO_CHAR |
TO_CHAR(col1, date_format) |
Formats a date as a character string. |
Oracle 23c continues to support
TO_CHAR for formatting dates, especially in reporting, SQL*Plus output, and application code.
- TO_CHAR remains the primary formatting function.
- Formatting behavior is influenced by
NLS_DATE_FORMAT unless a format model is explicitly supplied.
- Using a format model ensures deterministic output and is recommended in production SQL.
A format model defines how a DATE or TIMESTAMP should be displayed.
Example syntax:
TO_CHAR(date_column, 'DD-Mon-YYYY HH24:MI:SS')
Common date format symbols include:
Oracle provides multiple “current date/time” functions:
- SYSDATE — Date and time from the database server’s OS.
- CURRENT_DATE — Current date/time in the user’s session time zone.
- SYSTIMESTAMP — Full timestamp (fractional seconds, time zone).
SELECT SYSDATE FROM DUAL;
SYSDATE
---------
28-FEB-08
All three are fully supported in Oracle 23c and are foundational in time-based logic.