Search code examples
pythondatetime

How to increment a datetime by one day?


How to increment the day of a datetime?

for i in range(1, 35)
    date = datetime.datetime(2003, 8, i)
    print(date)

But I need pass through months and years correctly? Any ideas?


Solution

  • date = datetime.datetime(2003,8,1,12,4,5)
    for i in range(5): 
        date += datetime.timedelta(days=1)
        print(date)