跳到主要内容

Date & Time

Date and Time Data Types

NameAliasesStorage SizeResolutionMin ValueMax Value
DATE4 bytesday1000-01-019999-12-31
TIMESTAMPDATETIME8 bytesmicrosecond1000-01-01 00:00:009999-12-31 23:59:59.999999 UTC

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 |
+------------+----------------------------+