devxlogo

Presenting Dates in Varying Formats

Presenting Dates in Varying Formats

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:
  • The required date format is DD-MM-YYYY.
    Command: ALTER SESSION SET NLS_DATEFORMAT=’DD-MM-YYYY’

  • Example 3: The required date format is YYYY-MON-DD.
    Command: ALTER SESSION SET NLS_DATEFORMAT=’YYYY-MON-DD’

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.

See also  Small Business Strategies with Venmo
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist