跳至主要内容
跳至主要内容

Date

一个日期。以自 1970-01-01 以来的天数为单位存储,占用两个字节(无符号)。允许存储从 Unix Epoch 开始后到编译阶段定义的上限(当前为 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 │
└────────────┴──────────┘

参见

    © . This site is unofficial and not affiliated with ClickHouse, Inc.