Reputation: 2348
I want to get difference(in hours) between two timestamp in google bigquery; Please help.
Upvotes: 3
Views: 9290
Reputation: 203
Using StandardSQL
TIMESTAMP_DIFF(timestamp_expression1, timestamp_expression2, HOUR)
https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#timestamp_diff
Upvotes: 11
Reputation: 173171
Run below and you will see an idea to use
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
see more for Date and time functions and Mathematical functions
Upvotes: 2