【问题标题】:Clickhouse: how to convert date to long integer?Clickhouse:如何将日期转换为长整数?
【发布时间】:2019-02-20 17:51:22
【问题描述】:

我将日期作为“2018-01-02 12:12:22”形式的字符串字段,在 ClickHouse SQL 中将其转换为 long int 时间戳的正确方法是什么?

【问题讨论】:

    标签: sql date timestamp clickhouse


    【解决方案1】:

    我的查询返回不同的结果

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

    【讨论】:

      【解决方案2】:
      :) 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.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-04-20
        • 1970-01-01
        • 2016-08-13
        • 2021-08-17
        • 2018-10-16
        相关资源
        最近更新 更多