⏱️
BigQueryでtimestampの差分を出す
備忘録です。
公式ドキュメント
select
timestamp_diff(ts_end, ts_start, day) as diff_day,
timestamp_diff(ts_end, ts_start, hour) as diff_hour,
timestamp_diff(ts_end, ts_start, minute) as diff_minute,
timestamp_diff(ts_end, ts_start, minute) as diff_second,
timestamp_diff(ts_end, ts_start, millisecond) as diff_ms,
from
(
select
timestamp "2022-01-01 00:00:00+00" as ts_start,
current_timestamp() as ts_end
)
;
Discussion