First of all, sorry if this has been already answered, I have been searching for a while and did not find anything.
In short, I'm trying to create a programe to automate some tasks I have. In one, I have a loop on days, between a start date and an end date. For each iteration, I'm trying to get the lag in months between the current date and the start date. So I tried to use the euclidean division, which seemed appropriate. Bottom line is, it works for almost all dates except a few, for instance:
import datetime as dt
start=dt.date(2022, 7, 1)
end=dt.date(2023, 7, 1)
average_days=365/12
lag1=(end-start).days/average_days
lag2=(end-start).days//average_days
For these dates in particular, lag1 gives me 12 while lag2 gives me 11. Where does this difference come from exactly, and how can I work around this issue to continue using the euclidean division ?
Thank you