FormulaCraft

How to calculate the months between two dates in Excel and Google Sheets

Topic:Date arithmetic
Excel & Google Sheets
=DATEDIF(A2,B2,"M")

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Enter the start date in A2 and the end date in B2, both formatted as dates.
  2. 2In an empty cell, enter =DATEDIF(A2,B2,"M").
  3. 3The "M" unit returns the number of complete months (partial months are not counted).
  4. 4For fractional months, use =(B2-A2)/30.44 as an approximation.
  5. 5Press Enter to see the result.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

What is the difference between DATEDIF "M" and "YM"?

"M" returns total complete months between the two dates. "YM" returns only the months portion after subtracting complete years, useful for displaying '2 years and 5 months'.

Is there a MONTHS function in Excel?

Excel does not have a standalone MONTHS function. Use DATEDIF(start,end,"M") or the formula =(YEAR(B2)-YEAR(A2))*12+MONTH(B2)-MONTH(A2) for a simpler alternative.

More on Date arithmetic

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: