Split First and Last Name in Excel — With Examples (TEXTSPLIT, LEFT, FIND)
Learn how to split first and last name in Excel: TEXTSPLIT, LEFT and FIND formulas, middle names, Flash Fill and Text to...
Read Guide →You have two dates — a start date and an end date — and you want the months between them. Subtracting the dates only gives you days, and dividing the days by 30 is wrong, because months are not all 30 days long. Excel has a function for this, DATEDIF, but it does not appear when you type it, and it is not the only way: the same two dates can give you four different answers, and all four can be right, because they count different things. This guide gives you the formula first, works it through on real dates, shows you the four methods side by side on the same two pairs of dates, and tells you which one matches what you mean — plus the two errors that catch everyone, #NUM! and #VALUE!.
Quick takeaway: decide which months you mean, then pick the formula.
=DATEDIF(A2,B2,"m")=(YEAR(B2)-YEAR(A2))*12+MONTH(B2)-MONTH(A2)=YEARFRAC(A2,B2)*12=DATEDIF(A2,TODAY(),"m")
Four methods, four answers for the same two dates. The rule is:
DATEDIF counts months you have finished living through. The YEAR and MONTH method counts month labels you have passed.
Decide which one your business rule means before you pick a formula. For length of service, age and invoices, you almost always mean completed months — DATEDIF. For “how many calendar months does this span”, you mean the calendar method.
=DATEDIF(start_date, end_date, "m")
DATEDIF counts full months and ignores any leftover days that do not form another whole month.
Why does DATEDIF not appear when you type it? Microsoft does not document it and it is not in Excel’s function list or wizard — it is kept for compatibility with older spreadsheet programs. It works in every current version of Excel. You just have to type the whole name yourself, with no suggestion and no argument tooltip. If you type it correctly, Excel accepts it.
Start date in A2, end date in B2:
=DATEDIF(A2,B2,"m")
Result: 7. Seven complete months have passed. The extra 5 days are discarded, not rounded.
The boundary matters: 15 January to 14 March returns 1, because two complete months have not passed. 15 January to 15 March returns 2 — the second monthly step lands exactly on 15 March.
The same formula, applied to two pairs of dates. The second pair is deliberately awkward, because that is where the methods separate.
| Method | Formula | 15 Jan 2023 → 20 Aug 2023 | 31 Dec 2023 → 1 Jan 2024 | What it actually counts |
|---|---|---|---|---|
| DATEDIF | =DATEDIF(A2,B2,"m") | 7 | 0 | Completed whole months, leftover days discarded |
| Calendar months | =(YEAR(B2)-YEAR(A2))*12+MONTH(B2)-MONTH(A2) | 7 | 1 | Month boundaries crossed, day of month ignored |
| YEARFRAC | =YEARFRAC(A2,B2)*12 | 7.17 | about 0.03 | Elapsed time as a decimal, partial months included |
| Rounded up | =ROUNDUP(YEARFRAC(A2,B2)*12,0) | 8 | 1 | Any part of a month counts as a full month |
Check the calendar column: for 31 December 2023 to 1 January 2024, (2024 − 2023) × 12 + 1 − 12 = 12 − 11 = 1. One boundary crossed, even though only one day passed. And YEARFRAC for that pair is about 0.03 — one day is roughly three hundredths of a month.
Someone started work on 10 March 2021. Today is 10 September 2025. How long have they worked here?
=DATEDIF(A2,B2,"m") = 54. Check it: (2025 − 2021) × 12 + (9 − 3) = 48 + 6 = 54.=DATEDIF(A2,B2,"Y") = 4.=DATEDIF(A2,B2,"YM") = 6. “YM” counts the months ignoring the years — 54 months is 4 years and 6 months.=DATEDIF(A2,B2,"Y")&" years, "&DATEDIF(A2,B2,"YM")&" months" = “4 years, 6 months”.The same pattern works for age: start date is the date of birth, end date is TODAY(), and “Y” gives the age in whole years.
One warning: Microsoft recommends you do not use the “MD” unit (days ignoring months and years). In some cases it gives a negative number, zero, or a wrong result. Use “Y” and “YM” for years and months, and subtract the dates for days.
To count months from a start date up to today, and have the answer update every day:
=DATEDIF(A2,TODAY(),"m")
TODAY() supplies the current date, and Excel updates the result whenever the workbook recalculates. To count the complete months remaining from today to a planned end date:
=DATEDIF(TODAY(),B2,"m")
Two warnings: the first formula returns #NUM! if the start date is in the future. The second returns #NUM! after the planned end date has passed. Check the date order before using either one.
If you do not want to use DATEDIF — for example, because a colleague will not trust a function that does not appear in the list — you can calculate completed months with YEAR, MONTH and DAY:
=12*(YEAR(B2)-YEAR(A2))+MONTH(B2)-MONTH(A2)-(DAY(B2)<DAY(A2))
How it works: the first part counts calendar months, and the last part subtracts 1 when the end day is earlier in the month than the start day — because the final month is not complete yet. For 15 January to 20 August: 12 × 0 + 8 − 1 − 0 = 7. For 15 January to 14 March: 12 × 0 + 3 − 1 − 1 = 1. Same answers as DATEDIF, with no hidden function.
| Mistake | What happens | Fix |
|---|---|---|
| You subtracted the dates and divided by 30 | Wrong — months are 28 to 31 days long | Use DATEDIF with “m” |
| You used DATEDIF and got 0, but the dates are in different months | Correct — no whole month has finished yet | If you meant month boundaries, use the calendar formula |
| You typed DATEDIF and nothing appeared | It is not in Excel’s function list — no suggestion, no tooltip | Type the whole name yourself; Excel accepts it |
| Start date is after the end date | #NUM! error | Swap the dates, or check the date order first |
| A date is stored as text, not as a date | #VALUE! error | Fix the source date — convert it to a real date, do not hide the error |
| You used “MD” for the leftover days | Can give a negative number, zero, or a wrong result | Do not use “MD” — Microsoft recommends against it |
| You used TODAY() and the answer changed overnight | That is the point — TODAY() is always the current date | If you need a fixed answer, type the date instead of TODAY() |
| You counted months to today for a future start date | #NUM! — the start date has not happened yet | Check the date order before using the formula |
How do I calculate months between two dates in Excel? Use =DATEDIF(A2,B2,"m") for completed whole months. A2 is the start date, B2 is the end date, and “m” is the unit in double quotes.
Why does DATEDIF not show up in Excel? Microsoft does not document it and it is not in the function list. It works in every current version — type the whole name yourself, with no suggestion or tooltip.
How many months are between 15 January 2023 and 20 August 2023? 7 complete months with DATEDIF. 7 calendar months with the YEAR/MONTH formula. About 7.17 decimal months with YEARFRAC × 12. The right answer depends on which months you mean.
How do I count months between two dates including partial months? Use =YEARFRAC(A2,B2)*12 for a decimal answer, or =ROUNDUP(YEARFRAC(A2,B2)*12,0) to count any part of a month as a full month.
How do I get years and months between two dates? Use “Y” for the years and “YM” for the leftover months: =DATEDIF(A2,B2,"Y")&" years, "&DATEDIF(A2,B2,"YM")&" months". For 10 March 2021 to 10 September 2025 that gives “4 years, 6 months”.
Why does DATEDIF return #NUM!? The start date is after the end date. Swap them, or check the date order first.
How do I count months from a date to today? Use =DATEDIF(A2,TODAY(),"m"). TODAY() is the current date, so the answer updates every day.
Can I calculate months between dates without DATEDIF? Yes: =12*(YEAR(B2)-YEAR(A2))+MONTH(B2)-MONTH(A2)-(DAY(B2)<DAY(A2)). It gives the same completed months as DATEDIF.
That is the whole method: one function, DATEDIF with “m”, for the months you have finished living through — and the calendar formula, YEARFRAC or ROUNDUP when you mean something else. The only cases that need extra care are the start date coming after the end date, a date stored as text, and the “MD” unit that Microsoft itself warns against. Try it on your own dates now, with the 15 January to 20 August example above, and when you need to go the other way — adding months to a date instead of counting between two — the next guide to read is the add months to a date guide, which uses EDATE and EOMONTH for exactly that job.
Learn how to split first and last name in Excel: TEXTSPLIT, LEFT and FIND formulas, middle names, Flash Fill and Text to...
Read Guide →Learn how to get the month and year from a date in Excel: month name, month number, quarter, first and last day...
Read Guide →Learn how to extract text after a character in Excel: TEXTAFTER and TEXTBEFORE, the last word, and the older FIND method.
Read Guide →