Given a start date, how can I determine how many “business weeks” it’s been with Python? I can’t just divide by 7 because that won’t give me the correct answer.
An example would be a start date of Aug 1 2012 to the current date (Aug 13 2012) would output 3 weeks.
I’m basically trying to figure out from the start of the football season, what the current week (integer) is.
I’ve tried messing around with Pythons datetime module, but it’s been to no avail.
Try using datetime.weekday, datetime.isoweekday to get the current day of the week or use the more complete datetime.isocalendar to also get the current week of the year and using those as offsets to calculate an aligned difference.
So you can have a function like this:
With usage like this:
You can add
1to your week output depending on your chosen semantic of what a week difference should be.