Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigQuery SQL WHERE Date Between Current Date and -15 Days

I am trying to code the following condition in the WHERE clause of SQL in BigQuery, but I am having difficulty with the syntax, specifically date math:

WHERE date_column between current_date() and current_date() - 15 days 

This seems easy in MySQL, but I can't get it to work with BigQuery SQL.

like image 275
Eric Hendershott Avatar asked Dec 20 '16 13:12

Eric Hendershott


Video Answer


1 Answers

Use DATE_SUB

select *  from TableA where Date_Column between DATE_SUB(current_date(), INTERVAL 15 DAY) and current_date() 

Remember, between needs the oldest date first

like image 165
JohnHC Avatar answered Sep 18 '22 19:09

JohnHC