Excel guide · 2 min read
How to calculate months between two dates in Excel
Use =DATEDIF(B2,C2,"m") to count complete months between a start date in B2 and an end date in C2. To count calendar months regardless of the day, use =(YEAR(C2)-YEAR(B2))*12+MONTH(C2)-MONTH(B2).
Sample data
Every formula on this page was calculated live against this sheet.
| A | B | C | |
|---|---|---|---|
| 1 | Contract | Start | End |
| 2 | Lease | 2024-01-31 | 2026-03-15 |
| 3 | Support plan | 2025-06-01 | 2026-06-01 |
| 4 | Trial | 2026-09-20 | 2026-11-05 |
| 5 | Loan | 2025-04-10 | 2026-10-30 |
Complete months with DATEDIF
DATEDIF(start, end, "m") counts how many full months fit between the dates. A month only counts once the end date reaches the same day number. 31 January 2024 to 15 March 2026 is 25 complete months, since the 26th month would need to reach the end of March.
Result: 25
Returns 25 complete months for the lease.
Calendar months with YEAR and MONTH
Sometimes you want the difference in month numbers, ignoring the day: September to November is 2, whatever the dates. Multiply the year difference by 12 and add the month difference.
Compare with DATEDIF for the trial, 20 September to 5 November: DATEDIF says 1 complete month, this formula says 2 calendar months. Neither is wrong; pick the one that matches your rule.
Result: 2
Returns 2 calendar months for the trial.
Years and months together
For "1 year, 6 months" split the complete months into years and leftover months. DATEDIF with "y" gives whole years and MOD(months,12) gives the rest. Excel's DATEDIF also accepts "ym" for the leftover months directly.
Result: 1 yr 6 mo
Shows "1 yr 6 mo" for the loan.
Fractional months
For pro-rata billing you may want 1.5 months, not 1. =YEARFRAC(B4,C4)*12 returns months with decimals, based on a 30-day month by default. A simpler estimate is days divided by the average month length: =(C4-B4)/(365.25/12).
To count a partial month as a full one (for example "any part of a month is billed"), use DATEDIF and add 1 when the end day is past the start day.
Exactly one year
When the end date has the same day number, DATEDIF counts the final month. 1 June 2025 to 1 June 2026 is exactly 12 months.
Result: 12
Returns 12 for the support plan.
Common mistakes
#NUM! from DATEDIF
The start date is later than the end date. Swap them, or wrap with IFERROR if some rows are not finished yet.
Dividing days by 30
Months are 28 to 31 days long, so (C2-B2)/30 drifts over long periods. Use DATEDIF or YEARFRAC.
Expecting DATEDIF in autocomplete
DATEDIF is a hidden compatibility function. Type it in full; it still works in every version.
FAQ
What is the formula for months between two dates in Excel?
=DATEDIF(start,end,"m") for complete months. Use =(YEAR(end)-YEAR(start))*12+MONTH(end)-MONTH(start) to ignore the day of the month.
How do I calculate months from a date until today?
Use =DATEDIF(B2,TODAY(),"m"). It updates every day as months complete.
Why does DATEDIF give one month less than I expected?
It only counts complete months. 31 January to 28 February is 0 months because the end day has not reached 31. Use the YEAR and MONTH formula if you want calendar months.
How do I calculate years between two dates?
Use =DATEDIF(B2,C2,"y") for complete years. Use =YEARFRAC(B2,C2) if you need years with decimals, such as 2.12 years.
How do I count months including the start month?
Add 1 to the calendar-month formula: =(YEAR(C2)-YEAR(B2))*12+MONTH(C2)-MONTH(B2)+1. January to March then counts as 3 months, not 2.
Functions used
DATEDIFWhole years, months or days betweenYEARYear of a dateMONTHMonth numberMODRemainder after divisionTODAYToday’s date
Keep learning
- How to calculate days between two dates in Excel
- How to calculate age in Excel from date of birth
- How to add months to a date in Excel
Updated 2026-10-31