Work Week Calculator
Count work weeks and ISO week numbers in a date range.
A work week calculator helps you count the number of working weeks between two dates, which is useful for project planning, payroll periods, contract durations, and academic scheduling. Unlike simply dividing the number of days by 7, a proper work week count respects partial weeks and aligns with the ISO 8601 standard, which defines Monday as the first day of the week.
ISO week numbers are an internationally standardized way of labeling weeks within a year, widely used in Europe and in industries such as manufacturing, logistics, and construction. Week 1 of the ISO calendar is defined as the week containing the first Thursday of the year. This tool calculates both total work weeks in your date range and the ISO week number for each week.
To use the calculator, simply select a start date and an end date. The results include the total number of work weeks, a breakdown by month, and the corresponding ISO week numbers β all computed instantly in your browser without any data being sent to a server.
Frequently Asked Questions
Code Implementation
from datetime import date, timedelta
def get_iso_week(d: date) -> tuple[int, int]:
"""Return (iso_year, iso_week) for a date"""
iso = d.isocalendar()
return iso.year, iso.week
def get_monday_of_week(d: date) -> date:
"""Get the Monday of the week containing date d"""
days_since_monday = d.weekday() # Monday=0, Sunday=6
return d - timedelta(days=days_since_monday)
def count_work_weeks(start: date, end: date) -> list[dict]:
"""List all ISO work weeks in a date range"""
weeks = []
current = get_monday_of_week(start)
while current <= end:
iso_year, iso_week = get_iso_week(current)
friday = current + timedelta(days=4)
weeks.append({
'iso_year': iso_year,
'iso_week': iso_week,
'week_label': f'W{iso_week:02d}',
'start': current,
'end': friday,
'month': current.strftime('%B %Y'),
})
current += timedelta(weeks=1)
return weeks
# Usage
start = date(2026, 1, 1)
end = date(2026, 3, 31)
weeks = count_work_weeks(start, end)
print(f"Total work weeks: {len(weeks)}")
for w in weeks[:5]: # Show first 5
print(f" {w['week_label']} ({w['iso_year']}): {w['start']} - {w['end']}")
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.