7

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.

Community
  • 1
  • 1
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
  • 2
    Actually nm is a duplicate http://stackoverflow.com/questions/153584/how-to-iterate-over-a-timespan-after-days-hours-weeks-and-months-in-python .. didn't realize rrule(until=) takes any date object – Yuji 'Tomita' Tomita Feb 21 '11 at 00:16

0 Answers0