ehfeng
ehfeng

Reputation: 3865

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.

Upvotes: 7

Views: 22077

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

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)

Upvotes: 16

Related Questions