【问题标题】:presto/athena get next minute from current timestamppresto/athena 从当前时间戳获取下一分钟
【发布时间】:2021-10-03 06:43:48
【问题描述】:

如何从 presto/athena 中的current_timestamp 获得下一分钟

例如。

  1. 2021-07-27 12:29:52.951 UTC -> 2021-07-27 12:30:00.000 UTC
  2. 2021-07-27 12:29:25.951 UTC -> 2021-07-27 12:30:00.000 UTC

【问题讨论】:

    标签: amazon-web-services amazon-athena presto trino


    【解决方案1】:

    没有内置函数,但您可以通过在时间戳上添加 1 分钟然后使用 date_trunc 向下舍入到最接近的分钟来实现:

    WITH data(ts) AS (
        VALUES
            TIMESTAMP '2021-07-27 12:29:52.951 UTC',
            TIMESTAMP '2021-07-27 12:29:25.951 UTC'
    )
    SELECT ts, date_trunc('minute', ts + INTERVAL '1' MINUTE)
    FROM data
    

    =>

                 ts              |            _col1
    -----------------------------+-----------------------------
     2021-07-27 12:29:52.951 UTC | 2021-07-27 12:30:00.000 UTC
     2021-07-27 12:29:25.951 UTC | 2021-07-27 12:30:00.000 UTC
    (2 rows)
    

    【讨论】:

      猜你喜欢
      • 2021-02-02
      • 1970-01-01
      • 1970-01-01
      • 2021-12-04
      • 2013-12-20
      • 2011-12-26
      • 2012-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多