Umair Asghar
Umair Asghar

Reputation: 341

How to select data using where clause on timestamp in BigQuery?

I am trying to get data from a Bigquery table. In where clause i want to get the data on the basis of year like 2020. I am using EXTRACT(part FROM timestamp_expression [AT TIME ZONE timezone])

enter image description here

Query Looks like

  with input as (Select created_at as timestamp_value,user_id from `seraphic-spider-311810.Demo.table2`)
SELECT 
EXTRACT(Year FROM timestamp_value AT TIME ZONE "UTC") as year_value
FROM Input
where year_value like '2020%';

Upvotes: 1

Views: 1804

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172984

use WHERE EXTRACT(YEAR FROM timestamp_value) = 2020

Upvotes: 3

Related Questions