Populating a table with all dates in a given range in Google BigQuery -


is there convenient way populate table dates in given range in google bigquery? need dates 2015-06-01 till current_date(), this:

+------------+ | date       | +------------+ | 2015-06-01 | | 2015-06-02 | | 2015-06-03 | | ...        | | 2016-07-11 | +------------+ 

optimally, next step weeks between 2 dates, i.e.:

+---------+ | week    | +---------+ | 2015-23 | | 2015-24 | | 2015-25 | | ...     | | 2016-28 | +---------+ 

i've been fiddling around following answers found, can't them work, because core functions aren't supported , can't find proper ways replace them.

easiest way populate temp table dates between , including 2 date parameters

generate dates between date ranges

your appreciated!

best, max

all dates 2015-06-01 till current_date()

select date(date_add(timestamp("2015-06-01"), pos - 1, "day")) day (      select row_number() over() pos, *      (flatten((      select split(rpad('', 1 + datediff(timestamp(current_date()), timestamp("2015-06-01")), '.'),'') h      (select null)),h ))) 

all weeks between 2 dates

select year(day) y, week(day) w (   select date(date_add(timestamp("2015-06-01"), pos - 1, "day")) day   (        select row_number() over() pos, *        (flatten((        select split(rpad('', 1 + datediff(timestamp(current_date()), timestamp("2015-06-01")), '.'),'') h        (select null)),h   ))) ) group y, w 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -