Dates are generally a requirement for every application. However, including dates for users across the globe can be tedious, because different people use different formats to read the date.
Oracle has an easy way of presenting the dates to users, in the way they want: the variable NLS_DATEFORMAT.
- Example 1: The required date format is MM-DD-YYYY.
Command:ALTER SESSION SET NLS_DATEFORMAT=’MM-DD-YYYY’ - Example 2:
- Example 3: The required date format is YYYY-MON-DD.
Command: ALTER SESSION SET NLS_DATEFORMAT=’YYYY-MON-DD’
The required date format is DD-MM-YYYY.
Command: ALTER SESSION SET NLS_DATEFORMAT=’DD-MM-YYYY’
Because this change is only available only for the current session, everytime you open a session, you may need to set the required date format and from there use it as required.
If you want a certain format to be the default, irrespective of the session, you will need to modify the init.ora file.