Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def daterange(date1, date2, freq, multi, dt_format):
- start = datetime.strptime(date1, "%Y-%m-%d")
- end = datetime.strptime(date2, "%Y-%m-%d")
- while start < end:
- yield start, start + timedelta(**{freq: multi})
- start = start + timedelta(**{freq: multi})
- for from_dt, to_dt in daterange('2018-01-01', '2018-02-01', 'hours', 1, "%Y-%m-%dT%H:%M:%S"):
- print("Range:",from_dt,"-",to_dt)
Add Comment
Please, Sign In to add comment