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

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

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:

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

dan-irving

posted on

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