List of Datetime Format Elements in Oracle

Below is a full list of the datetime format elements in Oracle Database.

ElementTO_* datetime functions?Description
-
/
,
.
;
:
"text"
YesPunctuation and quoted text is reproduced in the result.
AD
A.D.
YesAD indicator with or without periods.
AM
A.M.
YesMeridian indicator with or without periods.
BC
B.C.
YesBC indicator with or without periods.
CC
SCC
Century.
DYesDay of week (1-7). This element depends on the NLS territory of the session.
DAYYesName of day.
DDYesDay of month (1-31).
DDDYesDay of year (1-366).
DLYesLong date format. Determined by the current value of the NLS_DATE_FORMAT parameter. The appearance of the date components (day name, month number, etc) depend on the NLS_TERRITORY and NLS_LANGUAGE parameters.

You can specify this format only with the TS element, separated by white space.
DSYesShort date format. The appearance of the date components (day name, month number, etc) depend on the NLS_TERRITORY and NLS_LANGUAGE parameters.

You can specify this format only with the TS element, separated by white space.
DYYesAbbreviated name of day.
EYesAbbreviated era name (Japanese Imperial, ROC Official, and Thai Buddha calendars).
EEYesFull era name (Japanese Imperial, ROC Official, and Thai Buddha calendars).
FF [1..9]YesFractional seconds. The optional numbers 1 to 9 specify the number of digits in the fractional second portion of the datetime value returned (e.g. FF3 for 3 digits). If you do not specify a digit, then Oracle Database uses the precision specified for the datetime data type or the data type’s default precision. Valid in timestamp and interval formats, but not in DATE formats.
FMYesReturns a value with no leading or trailing blanks.
FXYesRequires exact matching between the character data and the format model.
HH
HH12
YesHour of day (1-12).
HH24YesHour of day (0-23).
IWCalendar week of year (1-52 or 1-53), as defined by the ISO 8601 standard. A calendar week starts on Monday. The first calendar week of the year includes January 4. The first calendar week of the year may include December 29, 30 and 31. The last calendar week of the year may include January 1, 2, and 3.
IYYY4-digit year of the year containing the calendar week, as defined by the ISO 8601 standard.
IYY
IY
I
Last 3, 2, or 1 digit(s) of the year containing the calendar week, as defined by the ISO 8601 standard.
JYesJulian day; the number of days since January 1, 4712 BC. Number specified with J must be integers.
MIYesMinute (0-59).
MMYesMonth (01-12; January = 01).
MONYesAbbreviated name of month.
MONTHYesName of month.
PM
P.M.
YesMeridian indicator with or without periods.
QQuarter of year (1, 2, 3, 4; January – March = 1).
RMYesRoman numeral month (I-XII; January = I).
RRYesLets you store 20th century dates in the 21st century using only two digits.
RRRRYesRound year. Accepts either 4-digit or 2-digit input. If 2-digit, provides the same return as RR. If you do not want this functionality, then enter the 4-digit year.
SSYesSecond (0-59).
SSSSSYesSeconds past midnight (0-86399).
TSYesShort time format. Makes the appearance of the time components (hour, minutes, etc) depend on the NLS_TERRITORY and NLS_LANGUAGE initialisation parameters.

You can specify this format only with the DL or DS element, separated by white space.
TZD YesDaylight saving information. The TZD value is an abbreviated time zone string with daylight saving information. It must correspond with the region specified in TZR. Valid in timestamp and interval formats, but not in DATE formats.
TZHYesTime zone hour. Valid in timestamp and interval formats, but not in DATE formats.
TZMYesTime zone minute. Valid in timestamp and interval formats, but not in DATE formats.
TZRYesTime zone region information. The value must be one of the time zone region names supported in the database (see how to get valid time zones). Valid in timestamp and interval formats, but not in DATE formats.
WWWeek of year (1-53) where week 1 starts on the first day of the year and continues to the seventh day of the year.
WWeek of month (1-5) where week 1 starts on the first day of the month and ends on the seventh.
XYesLocal radix character. This is the symbol used to separate the integer part of the value from its fractional part.
Y,YYYYesYear with comma in this position.
YEAR
SYEAR
Year, spelled out; S prefixes BC dates with a minus sign (-).
YYYY
SYYYY
Yes4-digit year; S prefixes BC dates with a minus sign (-).
YYY
YY
Y
YesLast 3, 2, or 1 digit(s) of year.

The TO_* datetime functions? column determines whether or not the format element can be used with the TO_* functions (such as the TO_CHAR(datetime) function).

How to Use Format Elements

Format elements (sometimes referred to as format specifiers) can be used to construct datetime format models (sometimes referred to as format strings), which determine how the datetime value is displayed.

For example:

SELECT TO_CHAR(DATE '2035-09-26', 'DY, DD MONTH YYYY')
FROM DUAL;

Result:

WED, 26 SEPTEMBER 2035

In this case, I used a format model of DY, DD MONTH YYYY.

That format model consisted of a bunch of format elements. For example, DY is a format element, DD is another, as is MONTH and YYYY. Even the comma (,) is a format element.

Format elements that spell out a word (such as the day name or month name) can be provided in title case (with the first letter in uppercase and the remaining lowercase to produce a matching effect in the result:

SELECT TO_CHAR(DATE '2035-09-26', 'Dy, DD Month YYYY')
FROM DUAL;

Result:

Wed, 26 September 2035

Also, the output for such elements are subject to the session’s language:

ALTER SESSION SET NLS_DATE_LANGUAGE = 'SPANISH';
SELECT TO_CHAR(DATE '2035-09-26', 'Dy, DD Month YYYY')
FROM DUAL;

Result:

Mié, 26 Septiembre 2035

See How to Change the Language for your Oracle Session for more information and examples.

You might also be interested in How to Check the Values of the NLS Parameters.