Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get data that is no more than an hour old in BigQuery

Trying to use the statement:

SELECT * 
FROM data.example 
WHERE TIMESTAMP(timeCollected) < DATE_ADD(USEC_TO_TIMESTAMP(NOW()), 60, 'MINUTE') 

to get data from my bigquery data. It seems to return same set of result even when time is not within the range. timeCollected is of the format 2015-10-29 16:05:06.

I'm trying to build a query that is meant to return is data that is not older than an hour. So data collected within the last hour should be returned, the rest should be ignored.

like image 238
Nosakhare Belvi Avatar asked Nov 30 '22 17:11

Nosakhare Belvi


1 Answers

Using Standard SQL:

SELECT * FROM data
WHERE timestamp > TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL -60 MINUTE)
like image 59
Edo Avatar answered Dec 10 '22 11:12

Edo