Skip to main content
This topic describes the Firebolt implementation of the DATE data type.

Overview

The DATE type represents a calendar date, independent of a time zone.

Literal string interpretation

DATE literals follow the ISO 8601 format: YYYY-[M]M-[D]D.
  • YYYY: Four-digit year (0001 - 9999)
  • [M]M: One or two digit month (01 - 12)
  • [D]D: One or two digit day (01 - 31)
Examples

Functions and operators

Type conversions

The DATE data type can be cast to and from types as follows:

To DATE

From DATE

Comparison operators

A DATE value is also comparable with a TIMESTAMP or TIMESTAMPTZ value:
  • The DATE value is cast to the TIMESTAMP type for comparison with a TIMESTAMP value.
  • The DATE value is cast to the TIMESTAMPTZ type for comparison with a TIMESTAMPTZ value.

Arithmetic operators

The + operators described below come in commutative pairs:

Interval arithmetic

Arithmetic with intervals can be used to add or subtract a duration to or from a date. The result is of type TIMESTAMP. Example

Rows: 1Execution time: 9.42ms

Rows: 1Execution time: 5.88ms

For more information, see Arithmetic with intervals.

Serialization and deserialization

Text, CSV, JSON

In the text, CSV, and JSON format, a DATE value is output as a YYYY-MM-DD string. Input is accepted in the literal format described above: YYYY-[M]M-[D]D.

Parquet

DATE maps to Parquet’s 32-bit signed integer DATE type, also representing the number of days before or after 1970-01-01.

Avro

DATE maps to Avro’s 32-bit signed integer DATE type, also representing the number of days before or after 1970-01-01.

ORC

DATE maps to ORC’s signed integer DATE type, also representing the number of days before or after 1970-01-01.