FormatModels CheatSheet
FormatModels CheatSheet
Restrictions:
A comma cannot appear to the right of a decimal character or period in a number format
model.
, (comma) 9,999
Returns a decimal point, which is a period (.) in the specified position.
. (period) 99.99 Restriction: You can specify only one period in a number format model.
$ $9999 Returns value with a leading dollar sign.
0999 Returns leading zeros.
D 99D99 Restriction: You can specify only one decimal character in a number format model.
EEEE 9.9EEEE Returns a value using in scientific notation.
Returns in the specified position the group separator (the current value of the
NLS_NUMERIC_CHARACTER parameter). You can specify multiple group separators in a
G 9G999 number format model.
sql.standout-dev.com
Restriction: A group separator cannot appear to the right of a decimal character or period in a
number format model.
Returns in the specified position the local currency symbol (the current value of the
L L999 NLS_CURRENCY parameter).
Returns negative value with a trailing minus sign (-).
Restriction: The MI format element can appear only in the last position of a number format
MI 9999MI model.
Returns negative value in <angle brackets>.
Restriction: The PR format element can appear only in the last position of a number format
PR 9999PR model.
RN RN Returns a value as Roman numerals in uppercase.
Restriction: The S format element can appear only in the first or last position of a number format
S model.
The text minimum number format model returns (in decimal output) the smallest number of
characters possible. This element is case insensitive.
The default is TM9, which returns the number in fixed notation unless the output exceeds 64
characters. If the output exceeds 64 characters, then Oracle Database automatically returns the
number in scientific notation.
Restrictions:
sql.standout-dev.com
You can follow this element only with one 9 or one E (or e), but not with any combination of
these. The following statement returns an error:
Returns in the specified position the Euro (or other) dual currency symbol, determined by the
U U9999 current value of the NLS_DUAL_CURRENCY parameter.
Returns a value multiplied by 10n (and if necessary, round it up), where n is the number of 9's
V 999V99 after the V.
Returns the hexadecimal value of the specified number of digits. If the specified number is not an
XXXX integer, then Oracle Database rounds it to an integer.
xxxx Restrictions:
This element accepts only positive values or 0. Negative values return an error.
You can precede this element only with 0 (which returns leading zeroes) or FM. Any other
elements return an error. If you specify neither 0 nor FM with X, then the return always has one
leading blank. Refer to the format model modifier FM for more information.
X
sql.standout-dev.com
CC Century.
SCC
If the last 2 digits of a 4-digit year are between 01 and 99 (inclusive), then the century is one
greater than the first 2 digits of that year.
If the last 2 digits of a 4-digit year are 00, then the century is the same as the first 2 digits of
that year.
D Yes Day of week (1-7). This element depends on the NLS territory of the session.
DL Yes Restriction: You can specify this format only with the TS element, separated by white space.
Returns a value in the short date format. Makes the appearance of the date components (day
name, month number, and so forth) depend on the NLS_TERRITORY and NLS_LANGUAGE
parameters. For example, in the AMERICAN_AMERICA locale, this is equivalent to specifying
the format 'MM/DD/RRRR'. In the ENGLISH_UNITED_KINGDOM locale, it is equivalent to
specifying the format 'DD/MM/RRRR'.
DS Yes Restriction: You can specify this format only with the TS element, separated by white space.
E Yes Abbreviated era name (Japanese Imperial, ROC Official, and Thai Buddha calendars).
EE Yes Full era name (Japanese Imperial, ROC Official, and Thai Buddha calendars).
sql.standout-dev.com
Fractional seconds; no radix character is printed. Use the X format element to add the radix
character. Use the numbers 1 to 9 after FF to specify the number of digits in the fractional second
portion of the datetime value returned. 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.
Examples: 'HH:MI:SS.FF'
See Also: Additional discussion on this format model modifier in the Oracle Database SQL
FM Yes Language Reference
Requires exact matching between the character data and the format model.
See Also: Additional discussion on this format model modifier in the Oracle Database SQL
FX Yes Language Reference
HH
HH12
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.
IW
IYYY 4-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.
Julian day; the number of days since January 1, 4712 BC. Number specified with J must be
J Yes integers.
MI Yes Minute (0-59).
sql.standout-dev.com
MM Yes Month (01-12; January = 01).
RR Yes
Round year. Accepts either 4-digit or 2-digit input. If 2-digit, provides the same return as RR. If you
RRRR Yes do not want this functionality, then enter the 4-digit year.
Restriction: You can specify this format only with the DL or DS element, separated by white
TS Yes space.
Daylight 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.
TZD Yes Example: PST (for US/Pacific standard time); PDT (for US/Pacific daylight time).
Time zone hour. (See TZM format element.) Valid in timestamp and interval formats, but not in
DATE formats.
sql.standout-dev.com
Example: 'HH:MI:SS.FFTZH:TZM'.
Time zone region information. The value must be one of the time zone region names supported in
the database. Valid in timestamp and interval formats, but not in DATE formats.
Week of year (1-53) where week 1 starts on the first day of the year and continues to the seventh
WW day of the year.
W Week of month (1-5) where week 1 starts on the first day of the month and ends on the seventh.
Local radix character.
• Numeric elements are padded with leading zeros to the width of the maximum value allowed for the element. For example, the YYYY
element is padded to four digits (the length of '9999'), HH24 to two digits (the length of '23'), and DDD to three digits (the length of '366').
• The character elements MONTH, MON, DAY, and DY are padded with trailing blanks to the width of the longest full month name, the
longest abbreviated month name, the longest full date name, or the longest abbreviated day name, respectively, among valid names
determined by the values of NLS_DATE_LANGUAGE and NLS_CALENDAR parameters. For example, when NLS_DATE_LANGUAGE is
AMERICAN and NLS_CALENDAR is GREGORIAN (the default), the largest element for MONTH is SEPTEMBER, so all values of the
MONTH format element are padded to nine display characters. The values of the NLS_DATE_LANGUAGE and NLS_CALENDAR
parameters are specified in the third argument to TO_CHAR and TO_* datetime functions or they are retrieved from the NLS
environment of the current session.
• The character element RM is padded with trailing blanks to the length of 4, which is the length of 'viii'.
• Other character elements and spelled-out numbers (SP, SPTH, and THSP suffixes) are not padded.
The FM modifier suppresses the above padding in the return value of the TO_CHAR function.
sql.standout-dev.com
FX
Format exact. This modifier specifies exact matching for the character argument and datetime format model of a TO_DATE function:
• Punctuation and quoted text in the character argument must exactly match (except for case) the corresponding parts of the format model.
• The character argument cannot have extra blanks. Without FX, Oracle ignores extra blanks.
• Numeric data in the character argument must have the same number of digits as the corresponding element in the format model. Without
FX, numbers in the character argument can omit leading zeros.
When FX is enabled, you can disable this check for leading zeros by using the FM modifier as well.
If any portion of the character argument violates any of these conditions, then Oracle returns an error message.
sql.standout-dev.com