SyntaxStudy
Sign Up
Python Business Day Calculations
Python Intermediate 4 min read

Business Day Calculations

Business Days

Calculate working days, exclude weekends, and optionally exclude holidays using numpy.busday or pandas.

Example
import numpy as np
from datetime import date, timedelta

start = np.datetime64("2024-06-10")
end   = np.datetime64("2024-06-21")
bdays = np.busday_count(start, end)      # working days between
in_5  = np.busday_offset(start, 5)      # 5 business days from start

# Pure Python approach (weekdays only)
def add_business_days(dt, n):
    while n > 0:
        dt += timedelta(1)
        if dt.weekday() < 5: n -= 1
    return dt
Pro Tip

For production finance/HR apps, use a holiday calendar — numpy.busdaycalendar accepts holiday arrays.