Skip Headers

Oracle® OLAP DML Reference
10g Release 1 (10.1)

Part Number B10339-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

DATEFORMAT

The DATEFORMAT option holds the template used for displaying DATE values and converting DATE values to TEXT values. The template can include format specifications for any of the four components of a date (day, month, year, and day of the week). It can also include additional text.


See also:

MONTHNAMES option, DAYNAMES option, DATEORDER option.

Data type

TEXT

Syntax

DATEFORMAT = template

Arguments

template

A TEXT expression that specifies the template for displaying dates. Each component in the template must be preceded by a left angle bracket and followed by a right angle bracket. You can include additional text before, after, or between the components. The default template is '<DD><MTXT><YY>'.

Table 9-4, "DATEFORMAT Templates for Day", Table 9-5, "DATEFORMAT Templates for Week", Table 9-6, "DATEFORMAT Templates for Month", and Table 9-7, "DATEFORMAT Templates for Year" present the valid formats for each component. The tables provide two display examples, one for March 1, 1990 and another for November 12, 2051.

Table 9-4 DATEFORMAT Templates for Day

Format Meaning March 1, 1990 November 12, 2051
<D> One digit or two digits 1 12
<DD> Two digits 01 12
<DS> Space-padded, two digits 1 12
<DT> Ordinal, uppercase 1ST 12TH
<DTL> Ordinal, lowercase 1st 12th

Table 9-5, "DATEFORMAT Templates for Week" presents the valid formats for weeks. The table provides two display examples, one for March 1, 1990 and another for November 12, 2051.

Table 9-5 DATEFORMAT Templates for Week

Format Meaning March 1, 1990 November 12, 2051
<W> Numeric 4 1
<WT> First letter, uppercase W S
<WTXT> First three letters, uppercase. WED SUN
<WTXTL> First three letters, lowercase Wed Sun
<WTEXT> Full name, uppercase WEDNESDAY SUNDAY
<WTEXTL> Full name, lowercase Wednesday Sunday

Note that when you specify a format of <WTXT>, <WTXTL>, <WTEXT>, or <WTEXTL>, the case in which the value is specified in DAYNAMES effects the displayed value:

  • When the name in DAYNAMES is entered as all lowercase, the entire name is converted to uppercase. Otherwise, the first letter is converted to uppercase and the second and subsequent letters remain in their original case.

  • When the name in DAYNAMES is entered as all uppercase, the second and subsequent letters are converted to lowercase. Otherwise, the entire name remains in the case specified in DAYNAMES.

Table 9-6, "DATEFORMAT Templates for Month" presents the valid formats for months. The table provides two display examples, one for March 1, 1990 and another for November 12, 2051.

Table 9-6 DATEFORMAT Templates for Month

Format Meaning March 1, 1990 November 12, 2051
<M> One digit or two digits 1 11
<MM> Two digits 03 11
<MS> Space-padded, two digits 3 11
<MT> First letter, uppercase M N
<MTXT> First three letters, uppercase MAR NOV
<MTXTL> First three letters, lowercase Mar Nov

Note that when you specify a format of <MTXT> or <MTXTL>, the case in which the value is specified in MONTHNAMES effects the displayed value:

  • When the name in MONTHNAMES is entered as all lowercase, the entire name is converted to uppercase. Otherwise, the first letter is converted to uppercase and the second and subsequent letters remain in their original case.

  • When the name in MONTHNAMES is entered as all uppercase, the second and subsequent letters are converted to lowercase. Otherwise, the entire name remains in the case specified in MONTHNAMES.

Table 9-7, "DATEFORMAT Templates for Year" presents the valid formats for years. The table provides two display examples, one for March 1, 1990 and another for November 12, 2051.

Table 9-7 DATEFORMAT Templates for Year

Format Meaning March 1, 1990 November 12, 2051
<YY> Two digits or four digits 90 2051
<YYYY> Four digits 1990 2051

Notes


Angle Brackets

To include an angle bracket as additional text in a template, specify two angle brackets for each angle bracket to be included as text (for example, to display the entire date in angle brackets, specify '<<<D><M><YY>>>').


Month and Day Names

The names used in the month component for the MT, MTXT, MTXTL, MTEXT, and MTEXTL formats are drawn from the current setting of the MONTHNAMES option. The names used in the day-of-the-week component for the WT, WTXT, WTXTL, WTEXT, and WTEXTL formats are drawn from the current setting of the DAYNAMES option.


Abbreviations

You can set the DAYABBRLEN and MONTHABBRLEN options to use abbreviations of different lengths for day and month names.


Out-of-Range Years

When you specify the YY format, and a year outside the range of 1950 to 2049 is to be displayed, the year is displayed in four digits.


DATE-to-TEXT Conversion

When you use a DATE value where a text value (TEXT or ID) is expected, or when you store a DATE value in a TEXT variable, DATEFORMAT automatically converts the DATE value to a TEXT value. The current template in the DATEFORMAT option is used to format the text.

When you want to override the current DATEFORMAT template, you can convert the DATE value to TEXT by using the CONVERT function with a date-format argument. See the CONVERT function for an example.

Once a DATE value is stored in a TEXT variable, the DATEFORMAT template is no longer used to format the display of the value, and subsequent changes to DATEFORMAT have no impact.


Time Dimension Values

The DATEFORMAT option does not affect the way values of dimensions of type DAY, WEEK, MONTH, QUARTER, or YEAR are displayed. The display of DAY, WEEK, MONTH, QUARTER, and YEAR dimension values is controlled by a VNF (value name format) attached to the dimension definition, or by default conventions for DAY, WEEK, MONTH, QUARTER, and YEAR dimensions.

Examples

Example 9-31 Changing the Format of Dates

Example: The following statements define a DATE variable and set its value to March 24, 1997, then set the date format to two digits each in the order of day, month, and year, and send the result to the current outfile.

DEFINE datevar VARIABLE DATE
datevar = '24Mar97'
DATEFORMAT = '<DD>/<MM>/<YY>'
SHOW datevar

These statements produce the following output.

24/03/97

Example: The following statements change the date format to month (text), day (two digits), and year (four digits), and send the result to the current outfile.

DATEFORMAT = '<MTEXTL> <D>, <YYYY>'
SHOW DATEVAR

These statements produce the following output.

March 24, 1997

Example: The following commands change the date format to day of the week (text), month (text), day (one or two digits), and year (four digits), and send the result to the current outfile.

DATEFORMAT = '<WTEXTL> <MTEXTL> <D>, <YYYY>'
SHOW DATEVAR

These commands produce the following output.

Monday March 24, 1997

Example 9-32 Including Text in the Format of a Date

The following statements save and then change the DATEFORMAT option to include extra text for a workspace startup greeting.

PUSH DATEFORMAT
DATEFORMAT = 'Hello.  Today is <wtextl>, the <dtl> -
OF <MTEXTL>.'
SHOW TODAY
POP DATEFORMAT

When today's date is May 30, 1997, the following output is sent to the current outfile when the program is run.

Hello.  Today is Friday, the 30th of May.