1from datetime import date
2d0 = date(2017, 8, 18)
3d1 = date(2017, 10, 26)
4delta = d1 - d0
5print(delta.days)
1from datetime import datetime, timedelta
2
3def date_range(start, end):
4 delta = end - start # as timedelta
5 days = [start + timedelta(days=i) for i in range(delta.days + 1)]
6 return days
7
8start_date = datetime(2008, 8, 1)
9end_date = datetime(2008, 8, 3)
10
11print(date_range(start_date, end_date))
1from datetime import date, timedelta
2
3sdate = date(2008, 8, 15) # start date
4edate = date(2008, 9, 15) # end date
5
6delta = edate - sdate # as timedelta
7
8for i in range(delta.days + 1):
9 day = sdate + timedelta(days=i)
10 print(day)