Skip to main content

Time and Date Types

Data TypeSizeResolutionMin ValueMax ValuePrecision
Date2 byteday1000-01-019999-12-31YYYY-MM-DD
Date324 byteday1000-01-019999-12-31YYYY-MM-DD
DateTime/DateTime324 bytesecond1970-01-01 00:00:002105-12-31 23:59:59YYYY-MM-DD hh:mm:ss
DateTime648 bytenanosecond1677-09-21 00:12:44.02262-04-11 23:47:16.854775804YYYY-MM-DD hh:mm:ss.ff

For example:

CREATE TABLE dt
(
d Date,
t32 DateTime,
t64 DateTime64,
event_id UInt8
)
ENGINE = Memory;

INSERT INTO dt VALUES ('2021-09-09', '2021-09-09 01:01:01', '2021-12-21 01:01:01.123', 1);

mysql> select * from dt;
+------------+---------------------+-------------------------+----------+
| d | t32 | t64 | event_id |
+------------+---------------------+-------------------------+----------+
| 2021-09-09 | 2021-09-09 01:01:01 | 2021-12-21 01:01:01.123 | 1 |
+------------+---------------------+-------------------------+----------+