{
  "id": "years-between-dates",
  "version": "964aa5b82a19",
  "status": "published",
  "name": "Years Between Dates Calculator",
  "question": "How many years between two dates?",
  "summary": "Counts how many years are between two dates: whole years, months, and days, the same span as a decimal number of years, and the total months and days.",
  "category": "days",
  "subcategory": "dates",
  "url": "https://www.acalculator.org/days/years-calculator",
  "markdown": "https://www.acalculator.org/days/years-calculator.md",
  "kind": "function",
  "method": "years = the most whole years Y with start + Y years ≤ end, then months and days; decimal years = Y + (end − (start + Y years)) ÷ ((start + (Y + 1) years) − (start + Y years))",
  "assumptions": [
    "Dates are whole calendar days in the Gregorian calendar, with no time of day.",
    "An anniversary of February 29 falls on February 28 in a common year; a day that a month does not have moves to its last day.",
    "The decimal part is the days since the last anniversary divided by the days (365 or 366) until the next one.",
    "The end date is today unless you change it; the page reads today’s date from your device when it loads.",
    "A start date after the end date has no answer."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "start": {
        "title": "Start date",
        "description": "The earlier date.",
        "type": "string",
        "format": "date"
      },
      "end": {
        "title": "End date",
        "description": "The later date. Today, unless you change it.",
        "type": "string",
        "format": "date"
      }
    }
  },
  "outputs": {
    "span": {
      "label": "Time between",
      "description": "Whole years, then whole months, then days from the start date to the end date.",
      "format": "duration"
    },
    "years": {
      "label": "In years",
      "description": "Whole years plus the part of the next year that has passed: the days since the last anniversary ÷ the days in that anniversary year.",
      "format": "number"
    },
    "months": {
      "label": "Whole months",
      "description": "The number of whole calendar months from the start date to the end date.",
      "format": "integer"
    },
    "days": {
      "label": "Days",
      "description": "Calendar days from the start date to the end date.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "start": "2000-01-01",
      "end": "2026-09-30"
    },
    "outputs": {
      "span": {
        "years": 26,
        "months": 8,
        "days": 29
      },
      "years": 26.745205479452054,
      "months": 320,
      "days": 9769
    },
    "text": "From January 1, 2000 to September 30, 2026 is 26 years, 8 months, 29 days, or 26.75 years."
  },
  "examples": [
    {
      "given": {
        "start": "2000-01-01",
        "end": "2026-09-30"
      },
      "expect": {
        "span": {
          "years": 26,
          "months": 8,
          "days": 29
        },
        "years": 26.745205479452054,
        "months": 320,
        "days": 9769
      },
      "source": "Julian Day numbers (Meeus, Astronomical Algorithms, 1991, chapter 7): JD 2461313.5 − JD 2451544.5 = 9769 days; hand calculation in content.mdx; Python 3 cross-check in docs/progress/WP-56.md"
    },
    {
      "given": {
        "start": "1990-07-15",
        "end": "2026-03-10"
      },
      "expect": {
        "span": {
          "years": 35,
          "months": 7,
          "days": 23
        },
        "years": 35.652054794520545,
        "months": 427,
        "days": 13022
      },
      "source": "hand calculation in content.mdx; Python 3 cross-check in docs/progress/WP-56.md"
    },
    {
      "given": {
        "start": "2020-02-29",
        "end": "2021-02-28"
      },
      "expect": {
        "span": {
          "years": 1,
          "months": 0,
          "days": 0
        },
        "years": 1,
        "months": 12,
        "days": 365
      },
      "source": "Gregorian leap-year rule (ISO 8601); hand calculation in content.mdx"
    },
    {
      "given": {
        "start": "2024-02-29",
        "end": "2028-02-28"
      },
      "expect": {
        "span": {
          "years": 3,
          "months": 11,
          "days": 30
        },
        "years": 3.9972677595628414,
        "days": 1460
      },
      "source": "Gregorian leap-year rule (ISO 8601); hand calculation in content.mdx"
    }
  ],
  "sources": [
    "Jean Meeus, Astronomical Algorithms (1991), chapter 7: Julian Day numbers, so the days between two dates are the difference of their Julian Days.",
    "ISO 8601, Date and time format: the Gregorian calendar and its leap-year rule."
  ],
  "related": [
    "days-between-dates",
    "dob",
    "age-difference",
    "days-since"
  ],
  "changelog": []
}
