Python Practice › Datetime Programs › Program 11
Count business days
Write a Python program to count the working days (Monday to Friday) between two dates.
Input
2026-11-02 to 2026-11-30
Output
21
Approach
- Loop over each day and count weekdays.
Solution
from datetime import date, timedelta def business_days(start, end): count = 0 d = start while d <= end: if d.weekday() < 5: count += 1 d += timedelta(days=1) return count print(business_days(date(2026, 11, 2), date(2026, 11, 30)))Output
21
Learn the concept
New to this topic? Read the lesson, then come back.