Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DATE_ADD example for BigQuery returning error

Running examples from BigQuery docs and getting errors for intervals.

SELECT DATE_ADD(DATE "2008-12-25", INTERVAL 5 DAY) as five_days_later;

Returns...

Error: Encountered " <STRING_LITERAL> "\"2008-12-25\" "" at line 1, column 22. Was expecting: ")" ... [Try using standard SQL (https://cloud.google.com/bigquery/docs/reference/standard-sql/enabling-standard-sql)]

What am I missing here? Legacy SQL is checked.

like image 346
ehfeng Avatar asked Jul 11 '17 01:07

ehfeng


1 Answers

This example is for BigQuery Standard SQL

Try below

#standardSQL
SELECT DATE_ADD(DATE "2008-12-25", INTERVAL 5 DAY) AS five_days_later

... or just uncheck Legacy SQL :o)

like image 120
Mikhail Berlyant Avatar answered Nov 17 '22 09:11

Mikhail Berlyant