To find the number of full months between two dates in Excel, use the DATEDIF function. This formula returns the complete months elapsed, ignoring partial months, and works reliably across all modern Excel versions. No add-ins or external tools are required.
What You'll Need
- Microsoft Excel 2010 or later (including Excel for Microsoft 365, Excel for Mac, or Excel Online)
- Two valid date values in separate cells (e.g., start date in A1, end date in B1)
- Cells formatted as dates, not text
Step-by-Step
- Enter your start date in one cell (e.g., A1). Use a standard date format like 1/15/2023 or 15-Jan-2023. Avoid typing dates as text like "January 15, 2023" — Excel must recognize them as actual date values.
- Enter your end date in another cell (e.g., B1). Ensure this date is later than or equal to the start date. If the end date is earlier, the formula will return an error.
- Click on a blank cell where you want the result to appear (e.g., C1).
- Type the formula:
=DATEDIF(A1,B1,"m"). Replace A1 and B1 with the actual cell references containing your start and end dates. - Press Enter. Excel will display the number of complete months between the two dates. For example, if A1 is 1/15/2023 and B1 is 4/10/2023, the result will be 2, because only two full months (February and March) have passed.
- If your dates are in different columns or rows, adjust the cell references accordingly. For instance, if your start date is in D5 and end date in E5, use
=DATEDIF(D5,E5,"m"). - To apply the formula to multiple rows, click the cell with the formula, then drag the fill handle (small square in the bottom-right corner of the selected cell) down to copy it to other rows. Excel will automatically update the row numbers in the formula.
Common Mistakes
- Using text instead of actual dates: If Excel displays a date as text (left-aligned in the cell), DATEDIF will return a #VALUE! error. Fix this by selecting the cell, pressing F2, then Enter to reconfirm the date, or use the Text to Columns tool under the Data tab.
- Swapping start and end dates: If the end date comes before the start date, DATEDIF returns #NUM!. Always ensure the end date is chronologically after the start date.
- Using "md" or "ym" incorrectly: Some users try to use "md" (days between dates ignoring months) or "ym" (months ignoring years) when they want total months. Use only "m" for full months between two dates.
- Forgetting the quotes around "m": Writing =DATEDIF(A1,B1,m) without quotes causes a #NAME? error. The unit code must be enclosed in double quotes.
- Assuming partial months count: DATEDIF only counts complete months. If your start date is March 28 and end date is April 2, it returns 0, not 1. This is correct behavior — only full calendar months are included.
Tips
- Use the TODAY() function to calculate months from today: =DATEDIF(A1,TODAY(),"m") returns how many full months have passed since the date in A1 until today.
- Combine with IF statements to avoid errors: =IF(B1>A1,DATEDIF(A1,B1,"m"),"End date must be later") prevents #NUM! errors by checking date order first.
- Format the result cell as General or Number — not Date — so you see the numeric result clearly.
- If you need decimal months (e.g., 2.5 months), use a different approach: =(B1-A1)/30.44, where 30.44 is the average days per month. But note this is an approximation and not the same as DATEDIF’s integer result.
- For date ranges spanning multiple years, DATEDIF handles it automatically. From Jan 1, 2022 to March 15, 2024 returns 26 full months.
- Copy the formula to other cells and press Ctrl+Shift+Enter if you’re using an older Excel version that requires array handling (rare for DATEDIF).
Troubleshooting
- #VALUE! error: One or both cells contain text, not dates. Check cell formatting by selecting the cell and looking at the Number group on the Home tab. If it says "Text," convert it using the DATEVALUE function: =DATEVALUE(A1). Then copy the result and paste as values.
- #NUM! error: The end date is earlier than the start date. Double-check your cell references. If you intended the reverse, swap the cell references in the formula.
- #NAME? error: Excel doesn’t recognize "DATEDIF". This is extremely rare and usually means you mistyped the function. Verify spelling: D-A-T-E-D-I-F, not "DateDiff" or "DATEDIFF" (those are other functions).
- Result is zero when you expected more: You may have partial months. For example, from March 30 to April 1 is only 2 days — DATEDIF returns 0. If you need to count partial months, use the alternative formula: =(B1-A1)/30.44 and format the result as a number with two decimals.
- Formula shows as text: The cell might be formatted as Text. Right-click the cell, choose Format Cells, then select Number or General, then re-enter the formula.
- Formula works in one cell but not another: Check for hidden characters. Copy the working formula and paste it into the problematic cell using Paste Special > Values, then re-enter the cell references.