Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: PL/SQL
Expertise: Intermediate
Nov 22, 2005

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.

Sridhar MS
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap