{
  "id": "months-between-dates",
  "version": "79952b93b02f",
  "status": "published",
  "name": "Month Calculator",
  "question": "How many months between dates?",
  "summary": "Counts the months between two dates: whole months and days, the same span as a decimal number of months, in years, months, and days, and in days.",
  "category": "days",
  "subcategory": "dates",
  "url": "https://www.acalculator.org/days/month-calculator",
  "markdown": "https://www.acalculator.org/days/month-calculator.md",
  "kind": "function",
  "method": "months = the most whole months M with start + M months ≤ end; decimal months = M + (end − (start + M months)) ÷ ((start + (M + 1) months) − (start + M months))",
  "assumptions": [
    "Dates are whole calendar days in the Gregorian calendar, with no time of day.",
    "Adding months keeps the day of the month; a day that the month does not have moves to its last day, so January 31 plus 1 month is February 28 (or 29).",
    "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": {
    "months": {
      "label": "Months",
      "description": "Whole calendar months and the days left from the start date to the end date.",
      "format": "duration"
    },
    "decimal": {
      "label": "In months",
      "description": "Whole months plus the part of the next month that has passed: the days since the last monthly date ÷ the days to the next one.",
      "format": "number"
    },
    "span": {
      "label": "In years, months, and days",
      "description": "The same time as whole years, then whole months, then days.",
      "format": "duration"
    },
    "days": {
      "label": "Days",
      "description": "Calendar days from the start date to the end date.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "start": "2026-03-30",
      "end": "2026-09-30"
    },
    "outputs": {
      "months": {
        "months": 6,
        "days": 0
      },
      "decimal": 6,
      "span": {
        "years": 0,
        "months": 6,
        "days": 0
      },
      "days": 184
    },
    "text": "From March 30, 2026 to September 30, 2026 is 6 months (6 in decimal months)."
  },
  "examples": [
    {
      "given": {
        "start": "2026-01-15",
        "end": "2026-09-30"
      },
      "expect": {
        "months": {
          "months": 8,
          "days": 15
        },
        "decimal": 8.5,
        "span": {
          "years": 0,
          "months": 8,
          "days": 15
        },
        "days": 258
      },
      "source": "Julian Day numbers (Meeus, Astronomical Algorithms, 1991, chapter 7): JD 2461313.5 − JD 2461055.5 = 258 days; hand calculation in content.mdx"
    },
    {
      "given": {
        "start": "2026-01-31",
        "end": "2026-03-15"
      },
      "expect": {
        "months": {
          "months": 1,
          "days": 15
        },
        "decimal": 1.4838709677419355,
        "days": 43
      },
      "source": "Gregorian calendar month lengths (ISO 8601); hand calculation in content.mdx"
    },
    {
      "given": {
        "start": "2025-11-30",
        "end": "2026-02-28"
      },
      "expect": {
        "months": {
          "months": 3,
          "days": 0
        },
        "decimal": 3,
        "days": 90
      },
      "source": "Gregorian calendar month lengths (ISO 8601); hand calculation in content.mdx"
    },
    {
      "given": {
        "start": "2024-03-10",
        "end": "2026-05-20"
      },
      "expect": {
        "months": {
          "months": 26,
          "days": 10
        },
        "decimal": 26.322580645161292,
        "span": {
          "years": 2,
          "months": 2,
          "days": 10
        }
      },
      "source": "hand calculation in content.mdx; Python 3 cross-check in docs/progress/WP-56.md"
    }
  ],
  "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, its month lengths and leap-year rule."
  ],
  "related": [
    "days-between-dates",
    "years-between-dates",
    "weeks",
    "date"
  ],
  "changelog": [
    {
      "date": "2026-09-30",
      "note": "The answer names the decimal months as such, so whole months do not read twice."
    }
  ]
}
