Oracle date and timestamp formatting¶
In Oracle databases, the display format of dates and timestamps is controlled by session parameters. To prevent garbled or unreadable output, these parameters can be manually configured to ensure consistency.^[600-developer__database__oracle__oracle-record.md]
Formatting Parameters¶
The NLS_DATE_FORMAT parameter specifies the format for displaying DATE values, while NLS_TIMESTAMP_FORMAT handles TIMESTAMP values, including fractional seconds.^[600-developer__database__oracle__oracle-record.md]
SQL Commands¶
You can modify the format for the current session using the ALTER SESSION command.
Set Date Format:
alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';
Set Timestamp Format:
alter session set NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS:FF6';