Last active
April 23, 2018 22:07
-
-
Save carlynorama/3fe8daf9d2e561ca5faca44fcf48298f to your computer and use it in GitHub Desktop.
This file contains 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
#code taken from example on | |
#https://stackoverflow.com/questions/2003870/how-can-i-select-all-of-the-sundays-for-a-year-using-python | |
from datetime import date, timedelta | |
dstart = date(2018,1,1) | |
dend = date(2018,12,31) | |
# this will return all sundays between start-end dates. | |
days = [dstart + timedelta(days=x) for x in range((dend-dstart).days + 1) if (dstart + timedelta(days=x)).weekday() == 1] | |
print len(days) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment