difference in minutes between 2 bigquery timestamp fields

user3569267 picture user3569267 · May 16, 2014 · Viewed 29.8k times · Source

How can I get the difference in minutes between 2 timestamp fields in google bigquery? The only function I know is Datediff which gives the difference in day

Thanks

Answer

Paul Bendevis picture Paul Bendevis · Dec 2, 2016

Pentium10's answer works for Legacy SQL. If you're using Standard SQL you can use TIMESTAMP_DIFF and it will do the math for you:

TIMESTAMP_DIFF(timestamp_1, timestamp_2, MINUTE)

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