Skip to content
Advertisement

How to get all the dates between the date range (inclusive start_date and end_date) [closed]

How to get all the dates between start_date and end_date, including start_date and end_date?

But not those dates that do not fall in the range.

eg: 08-01-2020 should not be in the output because it is not in any of the work_id dates range so 08-01-2020 is one of the non-working dates

So I want all the dates except the non-working dates.

Sample table : enter image description here

Sample output : either this

enter image description here

or this

enter image description here

Advertisement

Answer

Create a list of dates of target range, add working and non-working flags to the list, and filter by the flag. You can get the expected output with the following query.

db<>fiddle

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement