Skip to main content

Date and Time Types

Date and Time


Data TypeSizeResolutionMin ValueMax ValuePrecision
Date2 byteday1000-01-019999-12-31YYYY-MM-DD
DateTime4 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

Example

mysql>
CREATE TABLE dt
(
date Date,
datetime DateTime,
datetime64 DateTime64
);
mysql>
desc dt;
+------------+---------------+------+---------+
| Field | Type | Null | Default |
+------------+---------------+------+---------+
| date | Date16 | NO | 0 |
| datetime | DateTime32 | NO | 0 |
| datetime64 | DateTime64(3) | NO | 0 |
+------------+---------------+------+---------+
mysql>
insert into dt values ('2022-04-07', '2022-04-07 01:01:01', '2022-04-07 01:01:01.123');
mysql>
select * from dt;
+------------+---------------------+-------------------------+
| date | datetime | datetime64 |
+------------+---------------------+-------------------------+
| 2022-04-07 | 2022-04-07 01:01:01 | 2022-04-07 01:01:01.123 |
+------------+---------------------+-------------------------+