---
title: "Days, months and business days between dates, add or subtract durations, ISO week numbers and day of year, and DST-aware elapsed time between local times."
method: POST
path: "/api/v1/date-calc"
tags: ["Converters"]
---

# Days, months and business days between dates, add or subtract durations, ISO week numbers and day of year, and DST-aware elapsed time between local times.

`POST /api/v1/date-calc`

## Request

- Base URL: `https://programmes.net`
- URL: `https://programmes.net/api/v1/date-calc`
- Auth: none declared

Date Calculator. Operations: `diff` — Difference between two dates in years/months/days, total days, weeks and business days. `add` — Add or subtract a duration ("1y 2m", "-90d", "P2W") or a number of business days. `info` — Weekday, day of year, ISO week, quarter and leap year for a date (plus Unix time of local midnight). `elapsed` — Exact elapsed time between two local date-times, following DST in each time zone.

## Request body

- union
  - DateCalcDiff: Difference between two dates in years/months/days, total days, weeks and business days.
    - `operation` 'diff', required
    - `input` string: Start date (YYYY-MM-DD).
    - `options` object, required
      - `end` string, required: End date (YYYY-MM-DD).
      - `holidays` string: Comma-separated YYYY-MM-DD dates excluded from business days.
  - DateCalcAdd: Add or subtract a duration ("1y 2m", "-90d", "P2W") or a number of business days.
    - `operation` 'add', required
    - `input` string: The date (YYYY-MM-DD).
    - `options` object
      - `duration` string: e.g. "30d", "1y 6m", "-2w", "P1M".
      - `businessDays` integer: Business days to add (negative to subtract), up to 1,000.
      - `holidays` string: Comma-separated holidays for businessDays.
  - DateCalcInfo: Weekday, day of year, ISO week, quarter and leap year for a date (plus Unix time of local midnight).
    - `operation` 'info', required
    - `input` string: The date (YYYY-MM-DD).
    - `options` object
      - `timeZone` string: IANA zone for the midnight timestamp.
  - DateCalcElapsed: Exact elapsed time between two local date-times, following DST in each time zone.
    - `operation` 'elapsed', required
    - `input` string: Start as "YYYY-MM-DD HH:MM".
    - `options` object, required
      - `end` string, required: End as "YYYY-MM-DD HH:MM".
      - `timeZone` string: IANA zone of the start.
      - `endTimeZone` string: IANA zone of the end (default: same).

## Response `200`

The operation ran.

- object
  - `ok` unknown, required
  - `tool` 'date-calc', required
  - `operation` 'diff' | 'add' | 'info' | 'elapsed', required
  - `result` unknown, required

## Other responses

- `400`: The request is not valid (https://programmes.net/api#invalid-request); The tool has no such operation (https://programmes.net/api#unknown-operation)
- `404`: No such tool (https://programmes.net/api#unknown-tool)
- `413`: The request or its input is too large (https://programmes.net/api#content-too-large)
- `415`: The body must be JSON (https://programmes.net/api#unsupported-media-type)
- `422`: An option is missing, of the wrong type or out of range (https://programmes.net/api#invalid-options); This call needs more CPU than one API call may use (https://programmes.net/api#refused); The operation could not process the input (https://programmes.net/api#tool-error)
- `429`: Too many requests (https://programmes.net/api#rate-limited)
- `500`: Internal error (https://programmes.net/api#internal-error)

---

[API](https://skmtc.dev/programmes/apis/programmes-net-api.md) · [All operations](https://skmtc.dev/programmes/apis/programmes-net-api/llms.txt) · [OpenAPI document](https://skmtc.dev/programmes/apis/programmes-net-api/revisions/aa939784a2e6?raw)
