You can change the date format in an Oracle session using the ALTER SESSION command with the NLS_DATE_FORMAT parameter. This affects how dates are displayed and how they're interpreted when converted to strings.
The most common approach is:
Replace 'YYYY-MM-DD' with your desired format. Common format patterns include:
DD-MON-YYYY(e.g., 15-JAN-2024)MM/DD/YYYY(e.g., 01/15/2024)YYYY-MM-DD HH24:MI:SS(includes time)DD/MM/YYYY(e.g., 15/01/2024)
This change applies only to your current session and is lost when you disconnect. To make it permanent, add the command to your login.sql file or set NLS_DATE_FORMAT in your environment variables.
Alternatively, use the TO_CHAR() function to format dates in specific queries without changing the session default:
You can also view your current date format with:
Be aware that changing session formats can affect how date strings are implicitly converted, which may impact application behavior if dates are compared as strings rather than date types.