Difference in decades between dates
The difference in decades calculator measures how many complete ten-year calendar periods separate two explicit ISO dates.
Run — free
Enter a starting date and an ending date in YYYY-MM-DD format, and it returns a signed integer: positive when the ending date is later, negative when it is earlier, and zero when fewer than ten whole years have elapsed. The calculation uses fixed Gregorian calendar rules in UTC, without the current time, a browser timezone, or any external service influencing the answer.
What a whole decade means in this calculator
A whole decade is a completed ten-year calendar interval measured from the first date, rather than a simple comparison of the decade labels printed on a calendar. From June 15, 2000 to June 14, 2020, only one full decade has completed because the second ten-year anniversary is still one day away. On June 15, 2020, the result becomes two. This distinction prevents dates near an anniversary from being rounded upward merely because their year numbers differ by twenty. It also means two dates can sit in different named decades while the answer remains zero. The output is deliberately an integer and discards any incomplete remainder after the last completed ten-year anniversary. That behavior is useful when a policy, archive, contract, or reporting rule speaks about completed decades rather than approximate elapsed time. Both inputs must be explicit ISO calendar dates in YYYY-MM-DD form, making the interpretation visible and reproducible.
Signed direction, UTC rules, and leap days
The sign follows the order in which you provide the dates. If the second date comes after the first, the count is positive. If the second date comes before the first, the same whole-decade magnitude is returned as a negative integer. Equal dates return zero. Reversing a pair therefore reverses the sign without changing its magnitude, which makes the value convenient for sorting, comparisons, and directional calculations. Calendar validation and arithmetic are performed with the proleptic Gregorian rules and do not call the JavaScript Date object. There is no local timezone conversion, daylight-saving transition, current clock, network lookup, or locale-dependent parser involved. For a starting date of February 29, its anniversary in a non-leap target year is treated as February 28. This explicit clamp supplies a stable answer for leap-day boundaries while keeping the calculation aligned with ordinary calendar-duration arithmetic. Years are accepted from 0001 through 9999.
How to use the result safely
Send the starting ISO date in the from field and the ending ISO date in the to field. The response repeats both validated inputs, provides the signed decades count, and labels the direction as forward, backward, or zero. Use the integer directly when you need completed ten-year periods, such as grouping long-running programs by elapsed decades, checking whether an anniversary threshold has passed, or describing the span between historical records. Do not treat it as a decimal estimate of years: a result of three says that three complete calendar decades have elapsed, not that the dates are exactly thirty years apart with no remaining months or days. Likewise, this capability does not infer dates from natural-language phrases, regional formats, timestamps, or the present moment. Those exclusions are intentional because explicit input is what makes repeated API calls deterministic. A request costs $0.002 through the API, while the browser version uses the same pure calculation for matching output.
What you can do with it
Check a long-term anniversary
Determine whether a project, institution, agreement, or collection has completed a specified number of ten-year anniversaries.
Compare historical records
Produce a stable signed decade span between two archival dates without depending on a workstation timezone or current clock.
Build deterministic reporting rules
Classify records by completed calendar decades using the same explicit boundary behavior in browser and API workflows.
FAQ
What does the sign mean?
A positive number means 'to' is later than 'from'; a negative number means it is earlier; zero means no whole decade separates them.
Does the calculator round partial decades?
No. It counts only completed ten-year calendar anniversaries and discards any incomplete remainder.
Which date format is accepted?
Both values must be explicit ISO calendar dates in YYYY-MM-DD format, with years from 0001 through 9999.
How is February 29 handled?
When a ten-year anniversary falls in a non-leap year, February 29 is clamped to February 28 for the comparison.
Does timezone or daylight saving time affect the answer?
No. The calculation uses date-only Gregorian calendar arithmetic deterministically in UTC and never reads the local timezone.
What does an API request cost?
Each API request costs $0.002. The calculation can also run free in the browser.
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/date/diff-in-decades \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"from":"1985-07-25","to":"2026-07-25"}'const res = await fetch("https://api.kit.forhosting.com/date/diff-in-decades", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"from": "1985-07-25",
"to": "2026-07-25"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/date/diff-in-decades",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"from": "1985-07-25",
"to": "2026-07-25"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/date/diff-in-decades", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"from":"1985-07-25","to":"2026-07-25"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"from":"1985-07-25","to":"2026-07-25"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/date/diff-in-decades", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"from": "1985-07-25",
"to": "2026-07-25"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "date.diff_in_decades",
"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.
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. |