Skip to content

Instantly share code, notes, and snippets.

@trfiladelfo
Created May 5, 2020 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trfiladelfo/5606630afe381d8ccfff6f2f5d40e3ee to your computer and use it in GitHub Desktop.
Save trfiladelfo/5606630afe381d8ccfff6f2f5d40e3ee to your computer and use it in GitHub Desktop.
interval in 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"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment