Skip to content

Instantly share code, notes, and snippets.

@ahmed4end
Created January 29, 2023 11:15
Show Gist options
  • Save ahmed4end/30f1e9d35f862376f153bb675eb5782b to your computer and use it in GitHub Desktop.
Save ahmed4end/30f1e9d35f862376f153bb675eb5782b to your computer and use it in GitHub Desktop.
How many of a certain day between two dates
import datetime
A1=datetime.datetime.strptime("21/10/2022", "%d/%m/%Y")
A2=datetime.datetime.strptime("29/01/2023", "%d/%m/%Y")
count=0
week="Fri"
for i in range ((A2-A1).days): #gives the no of days from A1 to A2
if A1.strftime("%a")==week:
count+=1
A1+=datetime.timedelta(days=1)
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment