Possible Duplicate:
How to iterate over a timespan after days, hours, weeks and months in Python?
I have two datetime.date
objects. I would like to iterate over all the months between them. (Being able to iterate over an arbitrary unit of time would be even better.) I'm not sure what the best way to go about this is.
Ideally, I'm looking for something like:
for month in (end - start).months:
# month is a date object
# ...
For example, if end
and start
are any dates in April and February, respectively, the result would be Feb, March, April.