for example, here is my data about people who use a drug X. ID start_date end_date 001 2020-01-10 2020-02-08 001 2020-02-09 2020-03-09 001 2020-03-01 2020-03-30 001 2021-05-07 2021-06-06 002 2020-07-01 2020-07-30 002 2020-07-26 2020-08-24 002 2020-08-15 2020-09-13 002 2021-05-07 2021-06-06 Assume the supply for this drug is 30 days . It is clear that there are days overlapped, in this case, I would like to add the overlapped days to the last end date for each time interval. e.g. For 001, there are 9 days overlapped (2020-03-01 to 2020-03-09); e.g. For 002, there are 5 days and 10 days overlapped; I wish I could have a simple time interval including start to end, and plus overlapped days. What I want to see is a dataset like this: ID start_date end_date 001 2020-01-10 2020-04-07 (2020-03-30 +9 days) 001 2021-05-07 2021-06-06 002 2020-07-01 2020-09-27 (2020-09-13 +5+10 days) 002 2021-05-07 2021-06-06 Hope I could get some help
... View more