get dates between two ranges

Solutions on MaxInterview for get dates between two ranges by the best coders in the world

showing results for - "get dates between two ranges"
Jonathan
06 Nov 2016
1import datetime
2
3d1 = datetime.date(2015, 1, 1)
4d2 = datetime.date(2015, 2, 6)
5days = [d1 + datetime.timedelta(days=x) for x in range((d2-d1).days + 1)]
6
7for day in days:
8    print(day.strftime('%Y%m%d'))
9    
10# ======================================================================== #
11import pandas
12
13pd.date_range('2012-05-25', '2012-06-27', freq='D')
14
15