I have two date ranges where each range is determined by a start and end date (obviously, datetime.date instances). The two ranges can overlap or not. I need the number of days of the overlap. Of course I can pre-fill two sets with all dates within both ranges and the perform a set intersection but this is possibly inefficient…is there a better way apart from another solution using a long if–elif section covering all cases?
I have two date ranges where each range is determined by a start and
Share
Here is an example calculation: