Site icon Nge Press

How to create a single date column from multiple date column with start date and end date?

I have a table with this kind of data, with no overlapping dates:

id start_date end_date
1 2021-12-20 2021-12-20
2 2021-12-15 2021-12-18
3 2021-12-10 2021-12-11

I want to have output as:

id date
1 2021-12-20
2 2021-12-18
2 2021-12-17
2 2021-12-16
2 2021-12-15
3 2021-12-11
3 2021-12-10

I tried creating table with generated dates between range min(start_date) and max(end_date) and using join with WHERE date>=start_date and date<=end_date.

Exit mobile version