{
  "id": "age-difference",
  "version": "5cadf9d72509",
  "status": "published",
  "name": "Age Difference Calculator",
  "question": "What is our age difference?",
  "summary": "Works out the gap between two birth dates in years, months, and days, the total days, and who is older.",
  "category": "days",
  "subcategory": "age",
  "url": "https://www.acalculator.org/days/age-difference-calculator",
  "markdown": "https://www.acalculator.org/days/age-difference-calculator.md",
  "kind": "function",
  "method": "From the earlier birth date, count whole years while the later birth date is not passed, then whole months, then the days left.",
  "assumptions": [
    "A month is counted when the same day of the month is reached; when that month is shorter, its last day counts (January 31 plus one month is February 28, or 29 in a leap year).",
    "A year from February 29 ends on February 28 in a common year.",
    "The difference is the same whichever person is entered first.",
    "Dates are calendar days with no time of day or time zone."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "name1": {
        "title": "First person’s name",
        "description": "A name for the first person, used in the answer.",
        "type": "string",
        "maxLength": 60
      },
      "birth1": {
        "title": "First person’s birth date",
        "description": "The first person’s date of birth.",
        "type": "string",
        "format": "date"
      },
      "name2": {
        "title": "Second person’s name",
        "description": "A name for the second person, used in the answer.",
        "type": "string",
        "maxLength": 60
      },
      "birth2": {
        "title": "Second person’s birth date",
        "description": "The second person’s date of birth.",
        "type": "string",
        "format": "date"
      }
    }
  },
  "outputs": {
    "difference": {
      "label": "Age difference",
      "description": "Whole years, then whole months, then days from the earlier birth date to the later one.",
      "format": "duration"
    },
    "older": {
      "label": "Who is older",
      "description": "Which person was born first.",
      "format": "text"
    },
    "days": {
      "label": "Total days",
      "description": "Days between the two birth dates.",
      "format": "integer"
    },
    "weeks": {
      "label": "Total weeks",
      "description": "The total days as whole weeks and days.",
      "format": "duration"
    },
    "months": {
      "label": "Total months",
      "description": "Completed months between the two birth dates.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "birth1": "2026-10-05",
      "birth2": "2026-10-05"
    },
    "outputs": {
      "difference": {
        "years": 0,
        "months": 0,
        "days": 0
      },
      "older": "Person 1 and Person 2 are the same age",
      "days": 0,
      "weeks": {
        "weeks": 0,
        "days": 0
      },
      "months": 0
    },
    "text": "Person 1 and Person 2 are the same age; the age gap is 0 days."
  },
  "examples": [
    {
      "given": {
        "birth1": "1990-05-15",
        "birth2": "1995-08-20"
      },
      "expect": {
        "difference": {
          "years": 5,
          "months": 3,
          "days": 5
        },
        "older": "Person 1 is older than Person 2",
        "days": 1923,
        "months": 63
      },
      "source": "hand calculation in content.mdx; Python: (date(1995,8,20) - date(1990,5,15)).days = 1923; U.S. Naval Observatory, Leap Years: the Gregorian leap year rule. https://aa.usno.navy.mil/faq/leap_years"
    },
    {
      "given": {
        "name1": "Ann",
        "birth1": "2010-06-01",
        "name2": "Bob",
        "birth2": "1970-06-01"
      },
      "expect": {
        "difference": {
          "years": 40,
          "months": 0,
          "days": 0
        },
        "older": "Bob is older than Ann",
        "days": 14610,
        "weeks": {
          "weeks": 2087,
          "days": 1
        }
      },
      "source": "hand calculation in content.mdx; Python: (date(2010,6,1) - date(1970,6,1)).days = 14610; U.S. Naval Observatory, Leap Years: the Gregorian leap year rule. https://aa.usno.navy.mil/faq/leap_years"
    },
    {
      "given": {
        "birth1": "2024-02-29",
        "birth2": "2025-03-01"
      },
      "expect": {
        "difference": {
          "years": 1,
          "months": 0,
          "days": 1
        },
        "days": 366
      },
      "source": "hand calculation in content.mdx; Python: (date(2025,3,1) - date(2024,2,29)).days = 366; U.S. Naval Observatory, Leap Years: the Gregorian leap year rule. https://aa.usno.navy.mil/faq/leap_years"
    },
    {
      "given": {
        "birth1": "1999-12-31",
        "birth2": "1999-12-31"
      },
      "expect": {
        "difference": {
          "years": 0,
          "months": 0,
          "days": 0
        },
        "older": "Person 1 and Person 2 are the same age",
        "days": 0
      },
      "source": "hand calculation in content.mdx: the same birth date; U.S. Naval Observatory, Leap Years: the Gregorian leap year rule. https://aa.usno.navy.mil/faq/leap_years"
    }
  ],
  "sources": [
    "U.S. Naval Observatory, Leap Years: the Gregorian leap year rule. https://aa.usno.navy.mil/faq/leap_years"
  ],
  "related": [
    "dob",
    "chronological-age",
    "days-between-dates"
  ],
  "changelog": [
    {
      "date": "2026-09-29",
      "note": "Worked examples name a published reference for their rule."
    }
  ]
}
