【问题标题】:difference in minutes between 2 bigquery timestamp fields2 个 bigquery 时间戳字段之间的分钟差
【发布时间】:2014-07-04 22:20:42
【问题描述】:

如何获得 google bigquery 中 2 个时间戳字段之间的分钟差? 我知道的唯一函数是 Datediff,它给出了天的差异

谢谢

【问题讨论】:

  • 有人知道日期时间字段的答案吗?
  • 您的费率很低。对 SO 很重要,您必须使用已发布答案左侧、投票下方的勾号来标记已接受的答案。这将提高您的费率。通过访问此链接了解其工作原理:meta.stackoverflow.com/questions/5234/…

标签: google-bigquery


【解决方案1】:

DATETIME_DIFF(datetime_1, datetime_2, MINUTE/SECOND)

【讨论】:

    【解决方案2】:

    Pentium10 的答案适用于 Legacy SQL。如果您使用的是标准 SQL,则可以使用 TIMESTAMP_DIFF,它会为您计算:

    TIMESTAMP_DIFF(timestamp_1, timestamp_2, MINUTE)
    

    https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#timestamp-functions

    【讨论】:

    • 注意:差异计算为timestamp_1 - timestamp_2
    【解决方案3】:

    使用TIMESTAMP_TO_USEC(<timestamp>) 并计算一下。

    https://developers.google.com/bigquery/query-reference#datetimefunctions

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多