(Python Example for Citizen Data Scientist & Business Analyst)
Write a Python program to get a list of dates between two dates.
from datetime import timedelta, date def daterange(date1, date2): for n in range(int ((date2 - date1).days)+1): yield date1 + timedelta(n) start_dt = date(2015, 12, 20) end_dt = date(2016, 1, 11) for dt in daterange(start_dt, end_dt): print(dt.strftime("%Y-%m-%d"))
2015-12-20 2015-12-21 2015-12-22 2015-12-23 2015-12-24 2015-12-25 2015-12-26 2015-12-27 2015-12-28 2015-12-29 2015-12-30 2015-12-31 ------- 2016-01-08 2016-01-09 2016-01-10 2016-01-11
Write a Python program to get a list of dates between two dates
Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.