0

In mysql, one can do this in order to compare 2 timestamp :

where UNIX_TIMESTAMP(transaction.closed_on)<UNIX_TIMESTAMP(transaction.opened_on)...

What’s the equivalent function for Google bigquery ?

user2284570
  • 2,891
  • 3
  • 26
  • 74

2 Answers2

0

... to subtract 2 timestamp : ...

you can use TIMESTAMP_DIFF(closed_on, opened_on, SECOND) for BigQuery Standard SQL

to compare in WHERE clause

WHERE closed_on < opened_on

finally, to convert timestamp to unix time ...

Use UNIX_SECONDS() function

Mikhail Berlyant
  • 165,386
  • 8
  • 154
  • 230
0

It is called UNIX_SECONDS:

select UNIX_SECONDS(TIMESTAMP("2008-12-25 15:30:00")) - UNIX_SECONDS(TIMESTAMP("2008-11-25 15:30:00"))
Yun Zhang
  • 5,185
  • 2
  • 10
  • 29