【发布时间】:2020-03-04 05:18:23
【问题描述】:
我正在尝试在 clickhouse 中比较日期时间。但它似乎以某种有线方式工作。 我的表中有一个列,我想与 (now(),'UTC') 进行比较。 如果该列中 datetime 的值小于 (now(),'UTC') 时间,那么我想从该记录中选择数据。
我已经创建了这样的表
create table my_table (`mytime` DateTime, `data' [type]) ENGINE= engine
我想要这样的队列
Select data from my_table where mytime < toDateTime(now(), 'UTC')
即使 mytime > toDateTime(now(), 'UTC') 它总是考虑 mytime
【问题讨论】:
-
toDateTime(now(), 'UTC') - 没有意义。 now() -- 已经是 UTC。存储在表中的 DateTime 是 UTC 中的 unixtime。 DateTime('UTC') -- 表示转换为String时转换为UTC。
标签: database datetime clickhouse