Programmer120
Programmer120

Reputation: 2592

How to get TIMESTAMP of 15 minutes ago using BigQuery?

Found this but this doesn't run on standard SQL

I tried to do:

WHERE datew > DATE_SUB(CURRENT_TIMESTAMP(),INTERVAL 5 DAY )

But this doesn't work. According to the docs DATE_SUB supports only

DAY
WEEK. Equivalent to 7 DAYs.
MONTH
QUARTER
YEAR

How can I get current time stamp - 15 minutes on standard SQL with BigQuery?

Upvotes: 1

Views: 9487

Answers (1)

AlienDeg
AlienDeg

Reputation: 1329

Check out timestamp_sub() function.

How to use it:

SELECT
CURRENT_TIMESTAMP() AS now, 
TIMESTAMP_SUB(CURRENT_TIMESTAMP(),INTERVAL 15 MINUTE) AS ago_15_min

Results

enter image description here

Upvotes: 8

Related Questions