Xerobit

Months Between Dates Calculator

Enter a start date and an end date to find out how many months between dates there are. The calculator returns full calendar months, leftover days, a decimal month value and the total day count. All arithmetic runs locally in your browser using UTC timestamps so daylight saving shifts never distort the result.

Result

  • Full months
    5
  • Leftover days
    5
  • Decimal months
    5.1253

    Total days / 30.4375

  • Total days
    156

How to use the months between dates

  1. Type the start date in YYYY-MM-DD format, for example 2026-01-15.
  2. Type the end date in the same format. It must fall on or after the start date.
  3. Read the results instantly: full calendar months, leftover days, decimal months and total days.

How the months between dates are calculated

The tool first counts whole calendar months by finding the largest N for which the start date plus N months does not pass the end date. Each candidate is always counted from the original start day, not from the previous result. Any remaining span becomes the leftover days.

Consider 2026-01-15 to 2026-06-20. Advancing five times reaches 2026-06-15, which is still on or before the end date. A sixth advance lands on 2026-07-15, which overshoots, so the answer is 5 full months. The leftover is 20 June minus 15 June, giving 5 days.

Decimal months divide the total day count by 30.4375, the average length of a Gregorian month (365.25 days per year divided by 12). For the example above, 156 total days divided by 30.4375 gives roughly 5.13 decimal months.

The borrowing rule for month-end dates

A common edge case arises when the start day is larger than the number of days in the target month. This is handled by a borrowing rule: if adding N months produces an invalid date like 31 April, the anchor snaps back to the last valid day of that month (30 April).

For example, from 2024-01-31 to 2024-03-01. Adding one month targets 31 February, but 2024 is a leap year so February has only 29 days. The anchor borrows down to 2024-02-29. That is one full month. The leftover is 1 March minus 29 February, which equals 1 day. Without this rule, the calculation would either fail or silently skip a month.

Reference table of common spans

The following table shows pre-computed results for typical date pairs. Use it to verify your own calculations or as a quick lookup.

StartEndFull monthsLeftover daysTotal days
2026-01-012026-04-013090
2026-01-152026-06-1550151
2025-11-302026-03-013191
2024-01-312024-03-312060
2026-02-282026-03-281028

Why UTC matters for date arithmetic

Local time zones shift clocks forward and backward for daylight saving time. If you subtract two local midnight timestamps across a DST boundary, the difference can be 23 or 25 hours instead of 24, throwing off day and month counts by one.

This calculator avoids that problem entirely by parsing each date string into a UTC timestamp via Date.UTC(year, monthIndex, day). Because UTC never observes daylight saving, every day is exactly 86,400,000 milliseconds. The result is deterministic regardless of where you open the page.

Practical uses for counting months

Knowing the exact months between two dates is useful in several everyday contexts:

  • Lease agreements: landlords and tenants need to confirm whether a tenancy covers 12 full calendar months or includes partial periods.
  • Subscription billing: SaaS platforms often prorate charges based on the fraction of a month used.
  • Pregnancy tracking: medical guidelines reference gestational age in both weeks and months.
  • Project planning: Gantt charts and roadmaps express milestones in month offsets from a start date.

For simpler day-only spans, see the days between dates calculator. If you need week-based intervals, the weeks between dates tool provides that breakdown.

Worked examples

ExampleInputResult
Half year spanStart date: 2026-01-01; End date: 2026-07-01Full months: 6; Leftover days: 0; Decimal months: 5.9466; Total days: 181
Cross-year with leftover daysStart date: 2025-10-15; End date: 2026-03-20Full months: 5; Leftover days: 5; Decimal months: 5.1253; Total days: 156
Same day different monthStart date: 2026-02-14; End date: 2026-03-14Full months: 1; Leftover days: 0; Decimal months: 0.9199; Total days: 28
Leap year FebruaryStart date: 2024-01-31; End date: 2024-03-01Full months: 1; Leftover days: 1; Decimal months: 0.9856; Total days: 30

FAQ

How do you calculate months between dates?

Count how many times you can add one calendar month to the start date without passing the end date. That count is the number of full months. The gap between the last valid monthly anniversary and the end date gives the leftover days.

What happens when the start date is the 31st and the target month has 30 days?

The calculator applies a borrowing rule: it clamps the anniversary to the last day of the shorter month. For instance, one month after 31 January is 28 or 29 February, not an invalid 31 February.

Why does the decimal month value use 30.4375?

A mean Gregorian year is 365.25 days. Dividing by 12 yields 30.4375 days per month on average. This constant converts a total day count into a fractional month figure.

Does this tool handle leap years correctly?

Yes. It validates every date against the actual calendar, so 29 February is accepted in leap years like 2024 and rejected in common years like 2026. Day totals reflect the extra day automatically.

Can I enter dates in formats other than YYYY-MM-DD?

No. The tool requires ISO 8601 format (YYYY-MM-DD) to avoid ambiguity between regional conventions like MM/DD/YYYY and DD/MM/YYYY.

Is my data sent to a server?

No. All calculations run locally in your browser. Nothing is uploaded anywhere.