Desk calendar with one date circled beside a stack of shipping boxes on a warehouse workbench

Calculate Business Days Excluding Holidays: A Colombia Case Study

•10 min read

If you need to calculate business days excluding holidays for delivery promises, payment terms, support SLAs or order cutoffs, a function that only skips weekends is not enough. A list of dates written by hand will also go out of date without anyone noticing. This guide uses Colombia as the example for three reasons: its calendar mixes fixed dates with dates based on Easter, the law moves some holidays to Monday, and the calendar changed in 2026. The same patterns work for any country you sell in.

Why "add N weekdays" breaks in production

Most date libraries include a helper that knows about weekends and nothing more. The date-fns addBusinessDays docs describe it as adding business days "(mon - fri)". It does exactly what it says, but it knows nothing about public holidays.

Here is a concrete case. In the official 2026 calendar published by Colombia's Ministry of Finance, December 8 (Immaculate Conception) falls on a Tuesday. Take an order placed on Friday, December 4, 2026, with "2 business days" handling. A weekend-only function returns Tuesday, December 8, which is a holiday. The correct answer is Wednesday, December 9. Monday, December 7, is a normal workday, and that day is the subject of our Día de las Velitas tech tips for Colombian businesses.

Colombia's calendar has three kinds of holidays:

  • Fixed dates that never move: January 1, May 1, July 20, August 7, December 8 and December 25.
  • Movable dates under Ley 51 de 1983 (the "Ley Emiliani"). As Portafolio explains, this law moves certain civil and religious holidays to the following Monday when they do not fall on a Monday. Buk's summary lists Epiphany, Saint Joseph, Saints Peter and Paul, the Assumption, Día de la Raza, All Saints and Cartagena's Independence among them.
  • Dates based on Easter: Holy Thursday and Good Friday, plus Ascension, Corpus Christi and Sacred Heart, which are also moved to Monday.

The list itself also changes. The official 2026 calendar includes a new national holiday, the Day of Our Lady of the Rosary of Chiquinquirá. It is commemorated on July 9, and in 2026 the day off is Monday, July 13 (Portafolio). Any library or hardcoded list written before that change gives wrong dates for July 2026, and it does so without raising an error.

Three architectures and their trade-offs

1. Compute holidays from rules at runtime

You write the rules in code (fixed dates, move-to-Monday, offsets from Easter) and compute any year when you need it. Open-source options exist. The holidays package on PyPI generates holiday lists by country, and smaller packages for Colombia such as colombia-utils and colombian-holidays cover local needs.

  • Pros: works for any year, no data to maintain, easy to unit test.
  • Cons: when the law changes, you have to wait for a new code release, either yours or the library's. Closures specific to your company do not fit this model.

2. Store a calendar table loaded from an official source

You keep one row per date with an is_business_day flag. Once a year, you load the rows from the government publication.

  • Pros: easy to audit, the operations team can edit it, simple to query from SQL and BI tools, and it supports closures for each company.
  • Cons: someone has to load next year before it starts. If they forget, every date calculation after December 31 is wrong.

3. Hybrid: rules generate, data confirms, company overrides come last

This is the pattern we recommend for most systems. A rules engine generates a draft calendar for future years. A person or a scheduled job compares it with the official publication and marks the year as verified. Company overrides, such as a warehouse closure or a day with shorter hours, live in a separate layer on top. The application only reads from the final stored table.

Data model

Keep three things separate: public holidays, company closures and operating hours. Mixing them causes most of the bugs in this area.

CREATE TABLE calendars (
  id          text PRIMARY KEY,          -- 'co-national', 'acme-bogota-warehouse'
  parent_id   text REFERENCES calendars(id),
  time_zone   text NOT NULL              -- IANA name, e.g. 'America/Bogota'
);

CREATE TABLE calendar_days (
  calendar_id      text NOT NULL REFERENCES calendars(id),
  day              date NOT NULL,
  is_business_day  boolean NOT NULL,
  reason           text,                 -- 'Inmaculada Concepción', 'inventory count'
  source           text NOT NULL,        -- 'rules-v3', 'official-2026', 'manual'
  PRIMARY KEY (calendar_id, day)
);

CREATE TABLE calendar_years (
  calendar_id  text NOT NULL REFERENCES calendars(id),
  year         int  NOT NULL,
  status       text NOT NULL CHECK (status IN ('draft','verified')),
  verified_by  text,
  verified_at  timestamptz,
  PRIMARY KEY (calendar_id, year)
);

A child calendar (one specific warehouse) inherits from its parent (the national calendar) and only stores the differences. Operating hours (a cutoff at a set local time, a half day on Saturday) go in their own table. "Is this a business day?" and "Is the warehouse open right now?" are different questions.

Generating the Colombian rules

This is the rules layer. The Easter function uses the well-known anonymous Gregorian algorithm. The result maps each date to a list of names. Two movable holidays can land on the same Monday, and a plain dictionary would quietly drop one of them.

from datetime import date, timedelta
from collections import defaultdict

def easter(y: int) -> date:
    a = y % 19
    b, c = divmod(y, 100)
    d, e = divmod(b, 4)
    f = (b + 8) // 25
    g = (b - f + 1) // 3
    h = (19 * a + b - d - g + 15) % 30
    i, k = divmod(c, 4)
    l = (32 + 2 * e + 2 * i - h - k) % 7
    m = (a + 11 * h + 22 * l) // 451
    month = (h + l - 7 * m + 114) // 31
    day = (h + l - 7 * m + 114) % 31 + 1
    return date(y, month, day)

def next_monday(d: date) -> date:
    return d + timedelta(days=(7 - d.weekday()) % 7)

FIXED   = [(1, 1), (5, 1), (7, 20), (8, 7), (12, 8), (12, 25)]
MOVABLE = [(1, 6), (3, 19), (6, 29), (7, 9), (8, 15), (10, 12), (11, 1), (11, 11)]
EASTER  = [(-3, False), (-2, False), (39, True), (60, True), (68, True)]

def colombia_holidays(year: int) -> dict[date, list[str]]:
    out = defaultdict(list)
    for m, d in FIXED:
        out[date(year, m, d)].append(f"fixed {m}-{d}")
    for m, d in MOVABLE:
        out[next_monday(date(year, m, d))].append(f"emiliani {m}-{d}")
    e = easter(year)
    for offset, moves in EASTER:
        d = e + timedelta(days=offset)
        out[next_monday(d) if moves else d].append(f"easter {offset:+d}")
    return dict(sorted(out.items()))

For 2026, this code produces 19 dates that match the Ministry of Finance list, including Tuesday, December 8 and Monday, July 13. Turn that comparison into a test. Keep a reference file for each year, copied from the official source, and add a CI check that fails if the generator disagrees with it. That is how you catch the next change in the law.

Adding business days fast

Once you have a sorted list of business days, adding N business days is a binary search. You do not need a loop that checks every date.

import bisect

def build_business_days(start: date, end: date, holidays: set[date]) -> list[date]:
    days, d = [], start
    while d <= end:
        if d.weekday() < 5 and d not in holidays:
            days.append(d)
        d += timedelta(days=1)
    return days

def add_business_days(days: list[date], start: date, n: int) -> date:
    i = bisect.bisect_right(days, start)   # first business day strictly after start
    if i + n - 1 >= len(days):
        raise LookupError("calendar not loaded far enough ahead")
    return days[i + n - 1]

# add_business_days(days, date(2026, 12, 4), 2) -> date(2026, 12, 9)

The same query in SQL, reading from the stored table:

SELECT day
FROM calendar_days
WHERE calendar_id = $1
  AND is_business_day
  AND day > $2
ORDER BY day
OFFSET $3 - 1
LIMIT 1;

The explicit LookupError matters. The worst failure is quietly falling back to "weekdays only" when data is missing, because it produces dates that look right and are wrong.

Cutoff times and time zones

"Orders before 2 p.m. ship the same business day" takes two steps. First, convert the moment of the order to the calendar's local date and time. Then decide the start date.

from datetime import datetime, time
from zoneinfo import ZoneInfo

def ship_date(order_at_utc: datetime, days: list[date], tz: str, cutoff: time) -> date:
    local = order_at_utc.astimezone(ZoneInfo(tz))
    today = local.date()
    if today in set(days) and local.time() < cutoff:
        return today
    return add_business_days(days, today, 1)

Never take the local date from the date part of a UTC timestamp. An order placed in the evening in Bogotá already carries the next day's date in UTC, and that moves every later calculation by one day.

Failure handling, integrity and security

  • Save the promise. Store the computed promised_date and the calendar_version on the order. After a calendar edit, never recompute dates you already showed to a customer.
  • Alert before the calendar runs out. A daily job checks that every active calendar has a verified year at least several months ahead, and sends an alert if not.
  • Limit and log edits. Changing the calendar changes payment due dates and deadlines. Limit who can edit it, log every change with the author and the reason, and require a review for national calendars.
  • Version the rules. Record the generator version (rules-v3) in the source column so you can see which logic produced each row.
  • Several countries. If you sell in Colombia, Mexico and the United States, you need one calendar per jurisdiction. Choose it by where the work happens (the warehouse, the support team), not by where the customer is.

This matters a lot in network marketing. Monthly qualification and commission cutoffs depend on which orders count for the period. Platforms built for that, like Ariani, Disruptive's network marketing platform, need cutoff rules that are explicit and easy to audit. For other businesses with their own scheduling logic, this is typical custom software development work.

Checklist to calculate business days excluding holidays

  1. Keep public holidays, company closures and operating hours separate.
  2. Generate future years from rules and check them against the official source.
  3. Keep a reference test for each year and make CI fail on any mismatch.
  4. Allow more than one holiday on the same date.
  5. Store an IANA time zone for each calendar and convert to local time before taking the date.
  6. Raise an error when a date goes past the loaded calendar. Never fall back quietly.
  7. Save promised dates and the calendar version used.
  8. Limit and log calendar edits.

Common mistakes

  • Using a helper that only skips weekends and calling it "business days".
  • Hardcoding one year's list of holidays and forgetting it exists.
  • Assuming a library is up to date after a change in the law, without a test to prove it.
  • Treating "business day" and "open now" as the same question.
  • Recomputing past promises after editing the calendar.

Frequently asked questions

Should I use a library or my own rules?

Either works if you test it against the official calendar every year. A library saves effort. Your own rules let you decide when to release the update after the law changes. Either way, you still need the stored table and the company overrides.

How far ahead should the calendar be loaded?

At least as far as your longest promise: payment terms, subscription renewals, contract deadlines. Set an alert well before you reach that point.

Do I need a calendar per city in Colombia?

For national holidays, one calendar is enough. Create child calendars for sites with their own closures or hours, and store only the differences.

Comments

No comments yet. Be the first to share what you think.

Leave a comment

It is never published.