shakti nayan
shakti nayan

Reputation: 13

BigQuery Filter by Date

I want to filter my data as per the DATE and TIME format '2016-01-09 16:31:04.000 UTC' using Legacy SQL in BigQuery. Kindly help me out with the correct syntax. I'm stuck.

Code

SELECT *
FROM
[table.column] AS Alias
WHERE
date >  '2017-03-31Z'; 

Upvotes: 1

Views: 6313

Answers (1)

akilesh raj
akilesh raj

Reputation: 674

If the type of your column is timestamp then,

SELECT timestamp
FROM [bigquery-public-data:openaq.global_air_quality]
where timestamp > '2018-01-01 00:00:00'

If the type of the column is `string, then you can try,

SELECT timestamp
FROM [bigquery-public-data:openaq.global_air_quality]
where timestamp(timestamp) > timestamp('2018-01-01 00:00:00')

For more BigQuery Legacy SQL functions go here

Upvotes: 5

Related Questions