David542
David542

Reputation: 110203

Bigquery date interval syntax

How would I do the following in BigQuery?

date in (now() - interval 1 day, now() - interval 2 day)

Basically, I want to get the following:

date IN ("2020-05-18", "2020-05-17")

Upvotes: 1

Views: 660

Answers (2)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

date in (DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY), DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY))

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1269873

How about direct comparisons:

date >= date('2020-05-17') and
date <= date('2020'05-18')

Or, if you prefer:

date in (date('2020-05-17'), date('2020'05-18'))

Upvotes: 0

Related Questions