DEV Community

Cover image for How to Check if a Date is a Business Day in Any Country (With Code Examples)
Digitaly
Digitaly

Posted on

How to Check if a Date is a Business Day in Any Country (With Code Examples)

Building an app that handles scheduling, invoicing, or delivery estimates? You'll need to know if a given date is a business day - and that's trickier than it sounds when you're dealing with multiple countries.

The Problem

A "business day" isn't universal:

  • Weekends vary: Saturday-Sunday in most countries, Friday-Saturday in UAE/Israel
  • Public holidays differ: France has 11, Japan has 16, the US has 11 federal holidays
  • Regional holidays exist: Bavaria (Germany) has holidays that don't apply in Berlin

Writing this logic from scratch means maintaining holiday calendars for 100+ countries. That's a maintenance nightmare.

The Solution: Use an API

Instead of hardcoding holiday data, call an API that handles it for you. Here's how to check if a date is a business day using the Public Holidays & Business Days API:

JavaScript/Node.js

const response = await fetch(
  'https://public-holidays-business-days-api.p.rapidapi.com/is-business-day?country=FR&date=2026-05-01',
  {
    headers: {
      'X-RapidAPI-Key': 'YOUR_API_KEY',
      'X-RapidAPI-Host': 'public-holidays-business-days-api.p.rapidapi.com'
    }
  }
);

const data = await response.json();
console.log(data);
// {
//   "date": "2026-05-01",
//   "country": "FR",
//   "isBusinessDay": false,
//   "reasons": [{ "type": "public_holiday", "name": "Labour Day", "localName": "Fête du Travail" }]
// }
Enter fullscreen mode Exit fullscreen mode

Python

import requests

response = requests.get(
    'https://public-holidays-business-days-api.p.rapidapi.com/is-business-day',
    params={'country': 'FR', 'date': '2026-05-01'},
    headers={
        'X-RapidAPI-Key': 'YOUR_API_KEY',
        'X-RapidAPI-Host': 'public-holidays-business-days-api.p.rapidapi.com'
    }
)

data = response.json()
print(f"Is business day: {data['isBusinessDay']}")
# Is business day: False
Enter fullscreen mode Exit fullscreen mode

Get the Next N Business Days

Need to calculate "delivery in 5 business days"? The API handles that too:

const response = await fetch(
  'https://public-holidays-business-days-api.p.rapidapi.com/next-business-day?country=US&date=2026-12-23&days=3',
  { headers: { 'X-RapidAPI-Key': 'YOUR_API_KEY', 'X-RapidAPI-Host': 'public-holidays-business-days-api.p.rapidapi.com' } }
);

const data = await response.json();
console.log(data.nextBusinessDays);
// ["2026-12-26", "2026-12-29", "2026-12-30"]
// (skips Dec 24-25 Christmas holidays and weekends)
Enter fullscreen mode Exit fullscreen mode

List All Public Holidays

Get all holidays for a country and year:

const response = await fetch(
  'https://public-holidays-business-days-api.p.rapidapi.com/holidays?country=DE&year=2026',
  { headers: { 'X-RapidAPI-Key': 'YOUR_API_KEY', 'X-RapidAPI-Host': 'public-holidays-business-days-api.p.rapidapi.com' } }
);

const data = await response.json();
console.log(`Germany has ${data.count} public holidays in 2026`);
Enter fullscreen mode Exit fullscreen mode

Why Not Build It Yourself?

You could use libraries like date-holidays (npm) or holidays (Python), but:

  1. Data gets stale - holidays change (UK added a bank holiday in 2022 for the Queen's funeral)
  2. Edge cases - some holidays are "observed" on different days when they fall on weekends
  3. Regional variations - the API handles sub-regions (US states, German Länder)

An API abstracts this complexity. You get accurate, up-to-date data without maintaining it yourself.

Pricing

The WorkDay API offers:

  • Free tier: 1,000 requests/month (enough for testing)
  • Pro: $9/month for 25,000 requests
  • Ultra: $29/month for 200,000 requests

Compare that to building and maintaining your own holiday database across 100+ countries.

Try It

  1. Sign up on RapidAPI
  2. Subscribe to the Public Holidays & Business Days API (free tier available)
  3. Make your first request

Building something that needs business day calculations? Drop a comment - I'd love to hear your use case.

Top comments (0)