Python : How to add month to December 2012 and get January 2013?
- by daydreamer
>>> start_date = date(1983, 11, 23)
>>> start_date.replace(month=start_date.month+1)
datetime.date(1983, 12, 23)
This works until the month is <=11, as soon as I do
>>> start_date = date(1983, 12, 23)
>>> start_date.replace(month=start_date.month+1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: month must be in 1..12
How can I keep adding months which increments the year when new month is added to December?