Guides

Add Business Days in JavaScript (Holidays Included)

date-fns ignores holidays

import { addBusinessDays } from "date-fns";
addBusinessDays(new Date("2026-11-25"), 2); // Fri Nov 27 — wrong for US banks (Thanksgiving)

addBusinessDays only skips Saturdays and Sundays. Every holiday becomes a bug.

DIY with a holiday set

function addBusinessDays(iso, n, holidays /* Set of "YYYY-MM-DD" */) {
  const d = new Date(iso + "T00:00:00Z");
  const step = Math.sign(n);
  let left = Math.abs(n);
  while (left > 0) {
    d.setUTCDate(d.getUTCDate() + step);
    const wd = d.getUTCDay();
    if (wd !== 0 && wd !== 6 && !holidays.has(d.toISOString().slice(0, 10))) left--;
  }
  return d.toISOString().slice(0, 10);
}

Use UTC to avoid DST off-by-one errors. Now you need correct holiday sets per calendar, kept up to date.

With Bankday

const url = new URL("https://bankday.jacklehoff4866.workers.dev/v1/business-days/add");
url.search = new URLSearchParams({ calendar: "us-fed", date: "2026-11-25", days: "2" });
const { result } = await (await fetch(url, {
  headers: { Authorization: `Bearer ${process.env.BANKDAY_KEY}` },
})).json(); // "2026-11-30"

Get a free API key

1,000 requests/month free. No credit card. Your key appears instantly.