Type Conversion Functions

Type Conversion Functions

The following table describes the value formats of the to_number function.

Table 1 Template patterns for numeric formatting

Schema

Description

9

Value with specified digits

0

Values with leading zeros

Period (.)

Decimal point

Comma (,)

Group (thousand) separator

PR

Negative values in angle brackets

S

Sign anchored to number (uses locale)

L

Currency symbol (uses locale)

D

Decimal point (uses locale)

G

Group separator (uses locale)

MI

Minus sign in the specified position (if the number is less than 0)

PL

Plus sign in the specified position (if the number is greater than 0)

SG

Plus or minus sign in the specified position

RN

Roman numerals (the input values are between 1 and 3999)

TH or th

Ordinal number suffix

V

Shifts specified number of digits (decimal)

The following table describes the patterns of date and time values. They can be used for the to_date, to_timestamp, and to_char functions, and the nls_timestamp_format parameter.

Table 2 Schemas for formatting date and time

Type

Schema

Description

Hour

HH

Number of hours in one day (01-12)

HH12

Number of hours in one day (01-12)

HH24

Number of hours in one day (00-23)

Minute

MI

Minute (00-59)

Second

SS

Second (00-59)

FF

Microsecond (000000-999999)

SSSSS

Second after midnight (0-86399)

Morning and afternoon

AM or A.M.

Morning identifier

PM or P.M.

Afternoon identifier

Year

Y,YYY

Year with comma (with four digits or more)

SYYYY

Year with four digits BC

YYYY

Year (with four digits or more)

YYY

Last three digits of a year

YY

Last two digits of a year

Y

Last one digit of a year

IYYY

ISO year (with four digits or more)

IYY

Last three digits of an ISO year

IY

Last two digits of an ISO year

I

Last one digit of an ISO year

RR

Last two digits of a year (A year of the 20th century can be stored in the 21st century.)

The password must comply with the following rules:

  • If the range of the input two-digit year is between 00 and 49:

    If the last two digits of the current year are between 00 and 49, the first two digits of the returned year are the same as the first two digits of the current year.

    If the last two digits of the current year are between 50 and 99, the first two digits of the returned year equal to the first two digits of the current year plus 1.

  • If the range of the input two-digit year is between 50 and 99:

    If the last two digits of the current year are between 00 and 49, the first two digits of the returned year equal to the first two digits of the current year minus 1.

    If the last two digits of the current year are between 50 and 99, the first two digits of the returned year are the same as the first two digits of the current year.

RRRR

Capable of receiving a year with four digits or two digits. If there are 2 digits, the value is the same as the returned value of RR. If there are 4 digits, the value is the same as YYYY.

  • BC or B.C.
  • AD or A.D.

Era indicator Before Christ (BC) and After Christ (AD)

Month

MONTH

Full spelling of a month in uppercase (9 characters are filled in if the value is empty.)

MON

Month in abbreviated format in uppercase (with three characters)

MM

Month (01-12)

RM

Month in Roman numerals (I-XII; I=JAN) and uppercase

Day

DAY

Full spelling of a date in uppercase (9 characters are filled in if the value is empty.)

DY

Day in abbreviated format in uppercase (with three characters)

DDD

Day in a year (001-366)

DD

Day in a month (01-31)

D

Day in a week (1-7).

Week

W

Week in a month (1-5) (The first week starts from the first day of the month.)

WW

Week in a year (1-53) (The first week starts from the first day of the year.)

IW

Week in an ISO year (The first Thursday is in the first week.)

Century

CC

Century (with two digits) (The 21st century starts from 2001-01-01.)

Julian date

J

Julian date (starting from January 1 of 4712 BC)

Quarter

Q

Quarter