cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
BigQuery, unlike other flavors of SQL, breaks out its tables by day. Each table has a suffix with the date included, but what if you want to allow your end-user to dynamically query only tables from certain dates?
By using table wildcard operators in conjunction with the built-in Date Range filter, this is definitely possible!

For StandardSQL
select
  *
from
 `table_prefix_*`
where
_TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d', [daterange_start]) AND FORMAT_DATE('%Y%m%d', [daterange_end])

For LegacySQL
#legacySQL
SELECT
  *
FROM
  TABLE_DATE_RANGE([project:dataset.tableprefix.table_prefix], TIMESTAMP([daterange_start]), TIMESTAMP([daterange_end]))
Rate this article:
Version history
Last update:
‎03-02-2023 08:59 AM
Updated by:
Contributors