Skip to main content

Date & Time

Date and Time Data Types


NameStorage SizeResolutionMin ValueMax ValueDescription
DATE4 bytesday1000-01-019999-12-31YYYY-MM-DD
TIMESTAMP8 bytesmicrosecond0001-01-01 00:00:009999-12-31 23:59:59.999999 UTCYYYY-MM-DD hh:mm:ss[.fraction], up to microseconds (6 digits) precision

Functions

See Date & Time Functions.

Example

CREATE TABLE test_dt
(
date DATE,
ts TIMESTAMP
);


DESC test_dt;
+-------+--------------+------+---------+-------+
| Field | Type | Null | Default | Extra |
+-------+--------------+------+---------+-------+
| date | DATE | NO | 0 | |
| ts | TIMESTAMP(6) | NO | 0 | |
+-------+--------------+------+---------+-------+

INSERT INTO test_dt VALUES ('2022-04-07', '2022-04-07 01:01:01.123456'), ('2022-04-08', '2022-04-08 01:01:01');

SELECT * FROM TEST_DT;
+------------+----------------------------+
| date | ts |
+------------+----------------------------+
| 2022-04-07 | 2022-04-07 01:01:01.123456 |
| 2022-04-08 | 2022-04-08 01:01:01.000000 |
+------------+----------------------------+