# Working days and business days calculator (`mangudai/working-days-business-days-calculator`) Actor

Count working days between two dates for 150+ countries. Removes weekends and public holidays, then returns one row per date range with the working day total and the holidays inside it. Offline, no API key, nothing to break.

- **URL**: https://apify.com/mangudai/working-days-business-days-calculator.md
- **Developed by:** [Mangudäi](https://apify.com/mangudai) (community)
- **Categories:** Open source, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Working days and business days calculator

Count the working days between two dates for more than 150 countries. The actor takes any number of date ranges and returns, for each one, the working days left after removing weekends and public holidays. It runs fully offline from a pinned copy of the `holidays` library, so there is no API key and nothing to break.

### What it does

Give it a start date and an end date and a country. It walks every day in the range and sorts each into weekend, public holiday, or working day. You get one clean row per query with the counts and the list of holidays that fell inside the range.

Typical uses:

- Payroll and billing periods where you pay per working day.
- Project and delivery estimates that skip weekends and national holidays.
- SLA and contract windows measured in business days.
- Leave and PTO planning across different countries.

### Input

- `queries`: a list of date ranges. Each item takes `startDate` and `endDate` in `YYYY-MM-DD` format, plus an optional `country` (ISO code like `US`, `GB`, `DE`, `FR`) and `subdivision` (like `ENG` for England or `CA` for California).
- `weekendDays`: which weekdays count as weekend, where 0 is Monday and 6 is Sunday. Defaults to Saturday and Sunday. Set it to `[4, 5]` for a Friday and Saturday weekend.

If a range is entered backwards, the actor swaps the dates and flags it with `datesReversed`.

### Output

One row per query with these fields:

- `startDate`, `endDate`: the normalized range.
- `country`, `subdivision`: what was used for the holiday calendar.
- `calendarDays`: total days in the range, inclusive.
- `weekendDays`: days that fell on a weekend.
- `publicHolidays`: holidays that fell on a working weekday.
- `workingDays`: days left after removing weekends and holidays.
- `holidaysInRange`: the dated list of holidays inside the range.
- `datesReversed`: true if the input dates were swapped.
- `error`: filled only when a query could not be processed.

Results export to JSON, CSV, or Excel from the dataset.

### Notes

Holiday coverage comes from the `holidays` library and follows official national calendars. Regional accuracy depends on passing the right subdivision. Countries observe holidays differently, so treat the working day count as the standard national reckoning, not local company policy.

# Actor input Schema

## `queries` (type: `array`):

One or more date ranges to measure. Each item needs startDate and endDate (YYYY-MM-DD) and an optional country and subdivision.
## `weekendDays` (type: `array`):

Weekday numbers treated as weekend, 0 is Monday and 6 is Sunday. Default is Saturday and Sunday.

## Actor input object example

```json
{
  "queries": [
    {
      "startDate": "2026-01-01",
      "endDate": "2026-03-31",
      "country": "US"
    },
    {
      "startDate": "2026-01-01",
      "endDate": "2026-12-31",
      "country": "GB",
      "subdivision": "ENG"
    },
    {
      "startDate": "2026-07-01",
      "endDate": "2026-07-31",
      "country": "FR"
    }
  ],
  "weekendDays": [
    5,
    6
  ]
}
````

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queries": [
        {
            "startDate": "2026-01-01",
            "endDate": "2026-03-31",
            "country": "US"
        },
        {
            "startDate": "2026-01-01",
            "endDate": "2026-12-31",
            "country": "GB",
            "subdivision": "ENG"
        },
        {
            "startDate": "2026-07-01",
            "endDate": "2026-07-31",
            "country": "FR"
        }
    ],
    "weekendDays": [
        5,
        6
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mangudai/working-days-business-days-calculator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "queries": [
        {
            "startDate": "2026-01-01",
            "endDate": "2026-03-31",
            "country": "US",
        },
        {
            "startDate": "2026-01-01",
            "endDate": "2026-12-31",
            "country": "GB",
            "subdivision": "ENG",
        },
        {
            "startDate": "2026-07-01",
            "endDate": "2026-07-31",
            "country": "FR",
        },
    ],
    "weekendDays": [
        5,
        6,
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("mangudai/working-days-business-days-calculator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queries": [
    {
      "startDate": "2026-01-01",
      "endDate": "2026-03-31",
      "country": "US"
    },
    {
      "startDate": "2026-01-01",
      "endDate": "2026-12-31",
      "country": "GB",
      "subdivision": "ENG"
    },
    {
      "startDate": "2026-07-01",
      "endDate": "2026-07-31",
      "country": "FR"
    }
  ],
  "weekendDays": [
    5,
    6
  ]
}' |
apify call mangudai/working-days-business-days-calculator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=mangudai/working-days-business-days-calculator",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Working days and business days calculator",
        "description": "Count working days between two dates for 150+ countries. Removes weekends and public holidays, then returns one row per date range with the working day total and the holidays inside it. Offline, no API key, nothing to break.",
        "version": "0.0",
        "x-build-id": "mJGOff0yG0aRKhIn6"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/mangudai~working-days-business-days-calculator/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-mangudai-working-days-business-days-calculator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/mangudai~working-days-business-days-calculator/runs": {
            "post": {
                "operationId": "runs-sync-mangudai-working-days-business-days-calculator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/mangudai~working-days-business-days-calculator/run-sync": {
            "post": {
                "operationId": "run-sync-mangudai-working-days-business-days-calculator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "queries": {
                        "title": "Date range queries",
                        "type": "array",
                        "description": "One or more date ranges to measure. Each item needs startDate and endDate (YYYY-MM-DD) and an optional country and subdivision."
                    },
                    "weekendDays": {
                        "title": "Weekend days",
                        "type": "array",
                        "description": "Weekday numbers treated as weekend, 0 is Monday and 6 is Sunday. Default is Saturday and Sunday.",
                        "default": [
                            5,
                            6
                        ]
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
