In python, subtracting two datetime.date objects results in a datetime.timedelta object that has the days attribute.
It is not possible to clearly determine the number of days of difference by year and month; if you define the year as 365 days and the month as 30 days, you can use:
years, remainder = divmod(diff1.days, 365) months = remainder
Or you could determine the average lengths of the year and month (slightly) more accurate:
avgyear = 365.2425
In the last calculation, your second difference arises as 11 years and 3 months.
Martijn pieters
source share