Is there a relatively simple way to create rows in a table based on a range of dates?
For example; given:
| ID | Date_min | Date_max |
|---|---|---|
| 1 | 2022-02-01 | 2022-20-05 |
| 2 | 2022-02-09 | 2022-02-12 |
I want to output:
| ID | Date_in_Range |
|---|---|
| 1 | 2022-02-01 |
| 1 | 2022-02-02 |
| 1 | 2022-02-03 |
| 1 | 2022-02-04 |
| 1 | 2022-02-05 |
| 2 | 2022-02-09 |
| 2 | 2022-02-10 |
| 2 | 2022-02-11 |
| 2 | 2022-02-12 |
I saw a solution when the range is integer based (How to create rows based on the range of all values between min and max in Snowflake (SQL)?)
But in order to use that approach GENERATOR(ROWCOUNT => 1000) I have to convert my dates to integers and back, and it just gets very messy very quick, especially since I need to apply this to millions of rows.
So, I was wondering if there is a simpler way to do it when dealing with dates instead of integers? Any hints anyone can provide?
