Skip to content
🛠️ToolsShed

Business Days Calculator

Count the number of working days between two dates, excluding weekends.

About this tool

A business days calculator counts the number of working days between two dates, excluding weekends and optionally holidays. It's essential for project managers, HR professionals, and business planners who need to accurately estimate timelines, deadlines, and resource allocation. Unlike a simple day counter, it reflects the actual days your team is working.

To use this tool, enter your start and end dates, and the calculator instantly shows how many business days fall between them. You can also add holidays to exclude them from the count, making the calculation precise for your specific calendar. This is particularly useful when planning deliverables, calculating turnaround times, or estimating SLA compliance.

Frequently Asked Questions

Code Implementation

from datetime import date, timedelta

def add_business_days(start: date, days: int, holidays: list[date] = None) -> date:
    """Add a given number of business days to a start date."""
    holidays = set(holidays or [])
    current = start
    remaining = days
    step = 1 if days >= 0 else -1

    while remaining != 0:
        current += timedelta(days=step)
        if current.weekday() < 5 and current not in holidays:  # Mon-Fri
            remaining -= step
    return current

def count_business_days(start: date, end: date, holidays: list[date] = None) -> int:
    """Count business days between two dates (exclusive of start)."""
    holidays = set(holidays or [])
    count = 0
    current = start
    while current < end:
        current += timedelta(days=1)
        if current.weekday() < 5 and current not in holidays:
            count += 1
    return count

# Example
start = date(2024, 1, 1)
result = add_business_days(start, 10)
print(f"10 business days after {start}: {result}")

biz_days = count_business_days(date(2024, 1, 1), date(2024, 1, 31))
print(f"Business days in January 2024: {biz_days}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.