跳到主要内容
跳到主要内容

Date

一个日期。以两个字节存储为自1970-01-01以来的天数(无符号)。允许存储从Unix纪元开始后的值到在编译阶段定义的常量所定义的上限(目前,这在2149年之前,但最终完全支持的年份是2148年)。

支持的值范围:[1970-01-01, 2149-06-06]。

日期值不存储时区。

示例

创建一个带有Date类型列的表并向其中插入数据:

CREATE TABLE dt
(
    `timestamp` Date,
    `event_id` UInt8
)
ENGINE = TinyLog;
-- Parse Date
-- - from string,
-- - from 'small' integer interpreted as number of days since 1970-01-01, and
-- - from 'big' integer interpreted as number of seconds since 1970-01-01.
INSERT INTO dt VALUES ('2019-01-01', 1), (17897, 2), (1546300800, 3);

SELECT * FROM dt;
┌──timestamp─┬─event_id─┐
│ 2019-01-01 │        1 │
│ 2019-01-01 │        2 │
│ 2019-01-01 │        3 │
└────────────┴──────────┘

另请参阅