Created
April 16, 2018 06:43
-
-
Save liudong/dcb168fd7544143713bb67c7b45ee11f to your computer and use it in GitHub Desktop.
Python: create a date range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def date_range(start_date, end_date): | |
start = datetime.datetime.strptime(start_date, "%Y-%m-%d") | |
end = datetime.datetime.strptime(end_date, "%Y-%m-%d") | |
return [start + datetime.timedelta(days=x) for x in range(0, (end-start).days)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment