DATE type

Represents values comprising values of fields year, month, and day, without a time-zone.

Syntax

DATE

Limits

The range of dates supported by date literals is January 1, 0 CE to December 31 9999 CE. However, the type supports June 23 -5877641 CE to July 11 +5881580 CE through date arithmetic.

Literals

DATE { 'yyyy' |
       'yyyy-[m]m' |
       'yyyy-[m]m-[d]d' |
       'yyyy-[m]m-[d]d[T]' }

yyyy: A four digit year between 0000 and 9999.

[m]m: A one or two digit month between 01 and 12.

[d]d: A one or two digit day between 01 and 31.

If the literal does represent a proper date Databricks raises an error.

Examples

> SELECT DATE'0000';
  0000-01-01
> SELECT DATE'2020-12-31';
  2020-12-31
> SELECT DATE'2021-7-1T';
  2021-07-01
> SELECT CAST('1908-03-15' AS DATE)
  1908-03-15
> SELECT DATE'9999' + INTERVAL '1' YEAR;
  +10000-01-01