Skip to content

Date32 ​

Date32 represents a Gregorian calendar date without a time of day or timezone. Its supported range is 1900-01-01 through 2299-12-31, inclusive.

Syntax ​

text
Date32

Input and conversion ​

Text input uses YYYY-MM-DD and must be a valid date within the supported range. Integer input is the number of days since 1970-01-01 and can be negative for earlier dates.

Casting a date to INTEGER returns its epoch-day count. Adding or subtracting an integer moves the date by that many days. Use an Interval for calendar-month or year arithmetic.

A Date compared with a timestamp represents midnight in the timestamp's timezone. Native date values cannot be summed directly; convert them explicitly when a numeric calculation is intended.

Examples ​

Creating a date column ​

sql
CREATE TABLE events(id UInt32, day Date32);
INSERT INTO events VALUES (1, '2100-01-01');
sql
SELECT id, day, day + 1 AS next_day
FROM events
FORMAT csv;
text
1,"2100-01-01","2100-01-02"

Converting epoch days ​

sql
SELECT CAST(1 AS Date32),
       CAST(CAST('1970-01-02' AS Date32) AS INTEGER)
FORMAT csv;
text
"1970-01-02",1

See Date for the alternative date range, and DateTime for whole-second timestamps.