Created
August 27, 2025 01:06
-
-
Save MikeiLL/6e734b0712b773a67264cda8f811bac1 to your computer and use it in GitHub Desktop.
Tuesdays and Thursdays in specified 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
from datetime import date, timedelta | |
sdate = date(2024, 9, 3) # start date | |
edate = date(2025, 5, 31) # end date | |
while sdate < edate: | |
if (sdate.weekday() != 1) and (sdate.weekday() != 3): # not tuesday or thursday | |
sdate += timedelta(days=1) | |
continue | |
# It is tuesday or thursday | |
print(sdate.strftime("%a %b %d %Y")) | |
if sdate.weekday() == 1: | |
sdate += timedelta(days=2) # next week | |
else: | |
sdate += timedelta(days=5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment