Skip to content

Instantly share code, notes, and snippets.

@alexflint
Last active January 4, 2022 16:09
Show Gist options
  • Save alexflint/f9f0dbd6ffffed5dd25cf16ea63bd748 to your computer and use it in GitHub Desktop.
Save alexflint/f9f0dbd6ffffed5dd25cf16ea63bd748 to your computer and use it in GitHub Desktop.
Date range from Google Data Studio in Bigquery SQL
SELECT
DATETIME(`begin`, 'US/Eastern') as `when`,
`host`,
`bytes`,
FROM
`mydataset.mytable`
WHERE
`begin` >= TIMESTAMP(PARSE_DATE('%Y%m%d', @DS_START_DATE), 'US/Eastern')
AND `begin` <= TIMESTAMP(DATE_ADD(PARSE_DATE('%Y%m%d', @DS_END_DATE), INTERVAL 1 DAY), 'US/Eastern')
# see https://support.google.com/datastudio/answer/10588439?p=bqparams&visit_id=637769059327596335-491020081&rd=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment