【发布时间】:2016-07-21 11:08:11
【问题描述】:
我想在 google bigquery 中获取两个时间戳之间的差异(以小时为单位); 请帮忙。
【问题讨论】:
标签: google-bigquery
我想在 google bigquery 中获取两个时间戳之间的差异(以小时为单位); 请帮忙。
【问题讨论】:
标签: google-bigquery
使用标准 SQL
TIMESTAMP_DIFF(timestamp_expression1, timestamp_expression2, HOUR)
https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#timestamp_diff
【讨论】:
在下面运行,你会看到一个使用的想法
SELECT
CURRENT_TIMESTAMP() AS timestamp_now,
TIMESTAMP(CURRENT_DATE()) AS timestamp_start_of_day,
FLOOR((CURRENT_TIMESTAMP() - TIMESTAMP(CURRENT_DATE()))/1000000/3600) AS diff_in_hours
【讨论】: