Sample Header Ad - 728x90

Postgres find gaps between one date range and others

1 vote
1 answer
1701 views
My question is similar to https://stackoverflow.com/a/41267928/2585154 , but in my case I need to divide/split date range by multiple date ranges, not only one. In my case is also guaranteed that "date ranges to split by" will not overlap with each other. **Example 1:** Date range to split: 2021-01-01 2021-12-31 Date ranges to split by (1): - 2021-03-01 2021-06-02 I want to get following output: - 2021-01-01 2021-02-28 - 2021-06-03 2021-12-31 **Example 2:** Date range to split: 2021-01-01 2021-12-31 Date ranges to split by (2): - 2021-03-01 2021-06-02 - 2021-07-01 2021-12-30 I want to get following output: - 2021-01-01 2021-02-28 - 2021-06-03 2021-06-30 - 2021-12-31 2021-12-31
Asked by Dmitry K. (143 rep)
Nov 28, 2021, 07:57 PM
Last activity: Nov 28, 2021, 11:11 PM