Skip to main content

Date & Time

Date and Time Data Types


NameStorage SizeResolutionMin ValueMax ValueDescription
DATE2 bytesday1000-01-019999-12-31YYYY-MM-DD
DATETIME4 bytessecond1970-01-01 00:00:002105-12-31 23:59:59YYYY-MM-DD hh:mm:ss
TIMESTAMP8 bytesnanosecond1677-09-21 00:12:44.0002262-04-11 23:47:16.854YYYY-MM-DD hh:mm:ss.ff

Functions

See Date & Time Functions.

Example

CREATE TABLE test_dt
(
date DATE,
datetime DATETIME,
datetime64 TIMESTAMP
);

DESC test_dt;
+------------+---------------+------+---------+
| Field | Type | Null | Default |
+------------+---------------+------+---------+
| date | Date16 | NO | 0 |
| datetime | DateTime32 | NO | 0 |
| datetime64 | DateTime64(3) | NO | 0 |
+------------+---------------+------+---------+

INSERT INTO dt VALUES ('2022-04-07', '2022-04-07 01:01:01', '2022-04-07 01:01:01.123');

SELECT * FROM dt;
+------------+---------------------+-------------------------+
| date | datetime | datetime64 |
+------------+---------------------+-------------------------+
| 2022-04-07 | 2022-04-07 01:01:01 | 2022-04-07 01:01:01.123 |
+------------+---------------------+-------------------------+