Number of days between dates
From 1 to 11 January 2024 there are 10 nights between the dates, or 11 days if the first and the last day both count. Pick the reading that matches your booking, leave form or listing. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Start
- 2024-01-01
- End
- 2024-01-11
- Endpoints
- Exclude
- Days
- 10
- Signed days
- 10
- Start year
- 2,024
Exclude returns the open interval — how many midnights sit strictly between the dates, the figure people use for nights in a hotel or days between events. Include returns that distance plus one, so the first day and the last day are both counted, which is the figure people use for days of leave, days of coverage, or days a listing stays live.
When counting both end days changes the answer
Travel planners use the exclude mode when a booking site sells nights and they need the integer that matches the folio, then flip to include when a traveler asks “how many days will I actually be away,” counting both the departure morning and the return evening as calendar days of the trip.
Human-resources and clinic desks use include when a leave form or an admission record covers every civil day from the first date through the last date, and they use exclude when a policy is written as “days after the event” rather than “days of coverage.” Landlords and marketplace sellers count inclusive listing days when a calendar shows a property occupied from Friday through Sunday as three days, and exclusive nights when the same stay is two nights of rent.
Teachers assign both modes so students can see why a spreadsheet that subtracts serial numbers silently disagrees with a phrase that says “including both dates.” Pair this landing with a days-until countdown when the question is remaining days to a future horizon, or with a weekend-count tool when only Saturdays and Sundays matter. Keep this page for the search “number of days” with an explicit include-or-exclude answer.
What you can do with it
Hotel nights versus calendar days of a stay
Turn check-in and check-out into nights (exclude) or calendar days of the trip (include) without timezone drift from the host clock.
Classroom and CI off-by-one checks
Show why “including both dates” is one more than a serial subtraction, and pin both integers in tests that must not depend on Date.
FAQ
What happens if I send the same date twice?
exclude returns 0 — there is no open gap. include returns 1 — that single civil day is the whole closed interval.
Why do I have to choose include or exclude?
Hotel nights, days of leave, and “how many days is the trip” disagree on whether both dates count.
What if one of the dates is not a real calendar day?
February 29 is accepted only in a leap year. Month lengths are checked on both fields.
What does the number-of-days calculator cost?
It is free in your browser on this page.
How many nights is a hotel stay from Monday to Thursday?
Three nights if you count the gap between the dates, and four calendar days if you count both the arrival and the departure day. The first figure matches the hotel bill, the second the days you are away.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/life/number-days \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"start":"2024-01-01","end":"2024-01-11"}'const res = await fetch("https://api.kit.forhosting.com/life/number-days", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"start": "2024-01-01",
"end": "2024-01-11"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/life/number-days",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"start": "2024-01-01",
"end": "2024-01-11"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/life/number-days", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"start":"2024-01-01","end":"2024-01-11"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"start":"2024-01-01","end":"2024-01-11"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/life/number-days", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"start": "2024-01-01",
"end": "2024-01-11"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "life.number_days",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
year_min | 1 |
year_max | 9999 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This number-of-days calculator answers a household planning question that spreadsheets still get wrong: given two calendar dates, what is the day count, and do both endpoints count? You send two ISO days in year-month-day form and an endpoints mode of exclude or include. If either input is not a real Gregorian calendar day, the request fails with invalid_input and is not charged. Successful API calls cost $0.002.
What include versus exclude changes in the number of days
People type “number of days between two dates”, “how many days is my trip”, or “number of days calculator” when they want a single integer, but they do not all agree on whether the first day and the last day count. Hospital admissions, rental contracts, school absences, visa-stay tallies, and “days this offer is live” use the same fork. Same-day pairs therefore yield zero under exclude and one under include. Times of day, time zones, and business-day calendars are out of scope: a midnight-to-midnight civil day is the unit. A hotel stay from Monday check-in through Thursday check-out is three nights if you exclude both endpoints as a gap, and four calendar days if you include the arrival day through the departure day. This page makes the choice explicit with an endpoints field: exclude returns the open interval, which is the absolute difference of two Gregorian serial day numbers; include returns that difference plus one so both endpoints sit inside the count. Reversing the pair never changes the absolute days figure; only signed_days flips sign so a pipeline can keep chronological direction. Because the implementation never constructs a JavaScript Date, the same pair and the same mode always yield the same integer whether it runs in a Worker, a browser in Tokyo, or a test harness with TZ set to America/New_York. That reproducibility is why the landing exists next to, not instead of, a plain days-between tool that never offers the include switch.
How the two ISO dates and the endpoints mode are read
The required fields are start and end, each a real calendar day in YYYY-MM-DD form. When it is omitted the engine defaults to exclude, matching the usual nights-between or midnights-between reading. Each date must be a real Gregorian day: four-digit year, two-digit month, two-digit day, with February twenty-nine allowed only in a leap year. Years are limited to the inclusive range one through nine thousand nine hundred ninety-nine so four-digit ISO strings stay well defined. Classic checks include twenty twenty-four dash zero one dash zero one to twenty twenty-four dash zero one dash one one under exclude yielding ten days, and twenty twenty-four dash zero two dash twenty-eight to twenty twenty-four dash zero three dash zero one under include yielding three days across a leap day. Aliases from, date1, begin, and a are accepted for the first date; aliases to, date2, finish, and b are accepted for the second, so a form, a query string, or a spreadsheet column can reuse the contract. The optional endpoints field is a closed enum: exclude or include. Aliases mode, count, and include_endpoints are accepted for the same switch. Missing fields, empty strings, non-string types, malformed patterns, impossible months, and non-leap twenty-ninth of February fail with invalid_input that names the field. A value of endpoints that is not exclude or include fails the same way. On success the body echoes the canonical start and end strings, the resolved endpoints mode, days as the non-negative count, signed_days with chronological direction, year-month-day components of both dates, and a short formula string. Successful API requests cost $0.002; invalid input is not billed.
Where a number-of-days count with an endpoint switch shows up
Because this capability is a pure parse engine, the work runs entirely in your browser on this page, and through the API each successful lookup costs $0.002 while failed validation does not consume balance. Nothing is stored after the response returns.
Integration use cases
Leave, coverage, and admission windows
Count every civil day from the first date through the last date when a form covers both endpoints, or the open gap when the policy is “days after.”
Technical questions
How is the number of days calculated when endpoints are excluded or included?
Both dates become Gregorian serial day numbers. exclude is the absolute difference. include is that difference plus one so both endpoints count. Send YYYY-MM-DD for start and end.