Ask Your Question
3

Can you add the dates for the upcoming 7 days in BigQuery?

asked 2023-06-26 04:06:13 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-26 04:35:01 +0000

djk gravatar image

Yes, here's an example of how to generate the dates for the next 7 days in BigQuery:

SELECT DATE_ADD(CURRENT_DATE(), INTERVAL n DAY) as date
FROM UNNEST(GENERATE_ARRAY(0, 6)) as n

This query uses the GENERATE_ARRAY function to create an array of numbers from 0 to 6 (i.e. 7 numbers), and then adds each number as an interval of days to the current date using DATE_ADD. This generates a list of dates for the next 7 days.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-26 04:06:13 +0000

Seen: 8 times

Last updated: Jun 26 '23