Date Calculator

Date Calculator API

Utilities

Add or subtract days, weeks, months and years from a date, add or count business days with Canadian, US or your own holidays, and find any date's weekday and ISO week.

Authentication

Send your API key as a Bearer token in the Authorization header (Authorization: Bearer YOUR_API_KEY), or in an X-API-Key header.

Rate Limit

120 requests per minute

Endpoints

1 endpoint available

Overview

One endpoint with four operations, chosen by operation:

  • add: add or subtract years, months, weeks and days from startDate.
  • add-business-days: move a number of business days forward or back, skipping days off and holidays.
  • count-business-days: count the business days between two dates.
  • date-info: weekday, ISO week, day of the year, quarter and leap year for a date.

Dates and time zones

  • Dates are plain calendar dates written YYYY-MM-DD, years 0001 to 9999, with no time zone. Nothing shifts with daylight saving.
  • add and date-info report how far the date is from a reference date (daysFromReference, positive when the date is after the reference). If you leave out referenceDate, it is today's date in UTC on the server. Send it for results that do not change from day to day.

Adding time

Years and months are added first as whole calendar months. If the day does not exist in the target month, it moves to the last day (January 31 plus one month is February 28, or 29 in a leap year) and monthEndAdjusted says so. Weeks and days are then added as exact days.

Business days

  • The start date is never counted: 1 business day after a Friday is the next Monday.
  • daysOff lists weekdays that are not working days, 0 for Sunday to 6 for Saturday. The default is [0, 6]. For add-business-days at least one day must be a working day.
  • holidayPreset adds Canada's federal statutory holidays or US federal holidays, computed for any year. With useObservedDates true, a holiday on a weekend moves to the day it is observed.
  • customHolidays takes one holiday per entry, like 2026-08-03 Civic Holiday. A date is required and any text after it is the name. Up to 500 entries.
  • count-business-days counts both ends by default and accepts dates in either order (datesSwapped tells you). The two dates must be less than 200 years apart.
  • Holidays that fall on a day off are not counted or skipped, since the day is already off.

Endpoints

POST
https://opentools.ca/api/v1/tools/date-calculator
Add or subtract time from a date, add or count business days, or look up facts about a date

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
operation
string
Enum: add, add-business-days, count-business-days, date-info
Required
What to calculate.
startDate
string
OptionalStart date, YYYY-MM-DD. Required for add, add-business-days and count-business-days.
endDate
string
OptionalEnd date, YYYY-MM-DD. Required for count-business-days.
date
string
OptionalThe date to look up, YYYY-MM-DD. Required for date-info.
referenceDate
string
Optionaladd and date-info only. The date to compare against. Defaults to today's date in UTC on the server.Default: today (UTC)
direction
string
Enum: add, subtract
Optionaladd and add-business-days only.Default: add
years
number
Optionaladd only. Whole years, up to 1,000,000.Default: 0
months
number
Optionaladd only. Whole months, up to 1,000,000.Default: 0
weeks
number
Optionaladd only. Whole weeks, up to 1,000,000.Default: 0
days
number
Optionaladd only. Whole days, up to 1,000,000.Default: 0
businessDays
number
Optionaladd-business-days only. Whole number, 0 to 100,000.Default: 0
includeStart
boolean
Optionalcount-business-days only. Count the start date.Default: true
includeEnd
boolean
Optionalcount-business-days only. Count the end date.Default: true
daysOff
array
OptionalBusiness-day operations only. Weekdays that are days off, 0 (Sunday) to 6 (Saturday).Default: [0, 6]
holidayPreset
string
Enum: none, ca-federal, us-federal
OptionalBusiness-day operations only. Built-in holidays to skip.Default: none
useObservedDates
boolean
OptionalBusiness-day operations only. Use the observed day for holidays that fall on a weekend.Default: true
customHolidays
array
OptionalBusiness-day operations only. Your own holidays as strings like "2026-08-03 Civic Holiday". Up to 500.Default: []

Response Example

{
  "success": true,
  "operation": "add",
  "startDate": "2026-01-31",
  "direction": "add",
  "date": "2026-03-14",
  "weekday": "Saturday",
  "dayDelta": 42,
  "monthEndAdjusted": {
    "requestedDay": 31,
    "usedDay": 28
  },
  "referenceDate": "2026-11-25",
  "daysFromReference": -256
}

Error Codes

400
Bad Request - A date is not a real YYYY-MM-DD date, a custom holiday cannot be read, every day is marked as a day off, the result falls outside years 1 to 9999, or the dates are 200 years or more apart
401
Unauthorized - Missing or invalid API key
403
Forbidden - The API key is inactive or expired, or the request IP is not allowed
405
Method Not Allowed - This endpoint accepts POST only
429
Too Many Requests - Rate limit exceeded (120 requests per minute per API key)
500
Internal Server Error

Code Examples

# Add one month and two weeks
curl -X POST https://opentools.ca/api/v1/tools/date-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "operation": "add",
  "startDate": "2026-01-31",
  "months": 1,
  "weeks": 2,
  "referenceDate": "2026-11-25"
}'

# Five business days after Dec 18, skipping Canadian holidays
curl -X POST https://opentools.ca/api/v1/tools/date-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "operation": "add-business-days",
  "startDate": "2026-12-18",
  "businessDays": 5,
  "holidayPreset": "ca-federal"
}'

# Business days in December
curl -X POST https://opentools.ca/api/v1/tools/date-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "operation": "count-business-days",
  "startDate": "2026-12-01",
  "endDate": "2026-12-31",
  "holidayPreset": "ca-federal"
}'

# Facts about a date
curl -X POST https://opentools.ca/api/v1/tools/date-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "operation": "date-info",
  "date": "2026-12-31",
  "referenceDate": "2026-11-25"
}'

Ready to get started?

Create an API key to start using the Date Calculator API.

Rather use it in your browser? Open the Date Calculator