I have the following code which works on a increament of month. However, after feburary it shows last day as 28 for each month. How can I get the actual last day of each month while increasing each month.
from dateutil.relativedelta import relativedelta
import datetime
from datetime import date
import time
Start_Date = date(2010, 01, 01)
End_Date = date(2010, 01, 31)
Final_startdate = date(2011, 12, 01)
while Start_Date < Final_startdate:
print Start_Date
print End_Date
Start_Date = Start_Date + relativedelta(months=+1)
End_Date = End_Date + relativedelta(months=+1)
This is what I get:
2010-01-01
2010-01-31
2010-02-01
2010-02-28
2010-03-01
2010-03-28
2010-04-01
2010-04-28
2010-05-01
2010-05-28
2010-06-01
2010-06-28
2010-07-01
2010-07-28
2010-08-01
2010-08-28