The python function relativedelta
calculates the time difference.
However, I get the wrong result.
from dateutil import relativedelta
y=relativedelta.relativedelta(pd.to_datetime('2006-01-11'), pd.to_datetime('1988-09-26')).years
m=relativedelta.relativedelta(pd.to_datetime('2006-01-11'), pd.to_datetime('1988-09-26')).months
y*12+m
207
# should be 208
But the above should be 208
since m
should equal to 4
instead of 3
.
Another example gets the correct result:
y=relativedelta.relativedelta(pd.to_datetime('2006-01-11'), pd.to_datetime('2003-04-04')).years
m=relativedelta.relativedelta(pd.to_datetime('2006-01-11'), pd.to_datetime('2003-04-04')).months
y*12+m
33
# CORRECT!
y=relativedelta.relativedelta(pd.to_datetime('2006-01-17'), pd.to_datetime('2001-12-20')).years
m=relativedelta.relativedelta(pd.to_datetime('2006-01-17'), pd.to_datetime('2001-12-20')).months
y*12+m
48
# should be 49
Any idea?