As an example I want to see what the date would be if it was today - 6 days. However, I only want to count days that are weekdays. So given 8/22 the output should be 8/12 as that is 6 business days only.
Tried using the weekday function to return if it is a 5 or 6 for saturday and sunday and skipping those days but I am not having luck so far
Current code:
from datetime import datetime, timedelta
age = 6
counter = 0
difference = datetime.today() - timedelta(counter)
while counter <= age:
difference = datetime.today() - timedelta(counter)
counter = counter + 1
this code only returns the day with the weekends included as I haven't been able to figure out how to exclude the weekend. I set up the code to loop to check if it is a 5 or 6 using the weekday() function but I keep getting bad results when attempting that