01 Feb 21 · dan-irving · #bigquery ·   Bookmark   ×

Google BigQuery Invalid date error in custom query in Data Studio

While using custom query (BigQuery) in Data Studio with  a date parameter, Data Studio throws the below error. Here is my query

SELECT * FROM `projectId.dataset.table1`
WHERE DATE(transaction_dt) > @DS_START_DATE
Invalid date: '20191014'

Solution:

The query parameters aren't really dates, but are strings in the format YYYYMMDD. So you need to parse them as dates in your query:

SELECT * FROM `projectId.dataset.table1` 
WHERE DATE(transaction_dt) > PARSE_DATE('%Y%m%d', @DS_START_DATE)

dan-irving

posted on 01 Feb 21

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds