I have a table with overlapping time periods for a number of units. For each unit, I would like to split the time period at the beginning and end of each temporal overlap.
Example with country-periods:
cntry | startdate | enddate |
A | 1960-01-01 | 1989-12-31 |
B | 1955-01-01 | 1974-12-31 |
B | 1975-01-01 | 1999-12-31 |
Desired output:
cntry | startdate | enddate |
A | 1960-01-01 | 1974-12-31 |
A | 1975-01-01 | 1989-12-31 |
B | 1955-01-01 | 1959-12-31 |
B | 1960-01-01 | 1974-12-31 |
B | 1975-01-01 | 1999-12-31 |
Also see this illustration here for clarification
This is closely related to a question I asked earlier, but could not be resolved with the solution used there. Any comments or suggestions on what would be the best approach in this case would be very welcome!