date

The date data type defines calendar dates.

Date values are automatically converted to and from the formats used by an external DBMS. Conversion operations from strings to dates, or from dates to strings or numbers require you to specify the format of the date value. To specify a date format, generate a string from the following codes and other literal strings or punctuation.

Date format code

Description

Example

DD

2-digit day of the month value (1-31)

The 2nd day of the month:

02

MM

2-digit month number (1-12)

The month of March:

03

MONTH

Full name of the month

The first month of the year:

JANUARY

MON

Abbreviated, three-character name of month

The first month of the year:

JAN

YY

2-digit year

A YY less than 15 is interpreted as being 20 <yy> ; for example, 10 would be interpreted as being the year 2010.

A YY greater than or equal to 15 is interpreted as being 19 <yy> ; for example, 35 would be interpreted as being the year 1935.

The year 1998:

98

YYYY

4-digit year

The year 1999:

1999

When you enter a date, use the default date format YYYY.MM.DD.

You can add and subtract date, datetime, interval, and time values; see Date Arithmetic.

The following examples show the use of date formats with functions. The value of the variable MyDate is the first day of 1996.

Example

Output

to_char($MyDate, 'YYYY.MM.DD')

1996.01.01

to_char($MyDate, 'MONTH DD, YYYY')

JANUARY 01, 1996

to_char($MyDate, 'DD/MM/YY')

01/01/96

to_date('01/01/96','DD/MM/YY')

1996.01.01 stored as a date

to_date('01/01/19','DD/MM/YY')

2019.01.01 stored as a date