clickhouse:如何将日期转换为长整数?

cwxwcias  于 2021-07-15  发布在  ClickHouse
关注(0)|答案(2)|浏览(618)

我将日期作为字符串字段,格式为“2018-01-02 12:12:22”,在clickhouse sql中,将其转换为long int timestamp的正确方法是什么?

gev0vcfq

gev0vcfq1#

:) SELECT toUInt64(toDateTime('2018-01-02 12:12:22'));

SELECT toUInt64(toDateTime('2018-01-02 12:12:22'))

┌─toUInt64(toDateTime('2018-01-02 12:12:22'))─┐
│                                  1514884342 │
└─────────────────────────────────────────────┘

1 rows in set. Elapsed: 0.001 sec.
erhoui1w

erhoui1w2#

我的查询返回不同的结果

SELECT toUInt64(toDateTime('2018-01-02 12:12:22', 'UTC'))

┌─toUInt64(toDateTime('2018-01-02 12:12:22', 'UTC'))─┐
│                                         1514895142 │
└────────────────────────────────────────────────────┘

相关问题