To calculate the number of whole months between two dates in Excel or Google Sheets, use =DATEDIF(start_date, end_date, "m"). That single formula returns a full integer count of completed months, ignoring the leftover days. If you need the count rounded, inclusive of partial months, or shown as years and months together, the same function and a couple of variations will cover you. All you need are two real dates in separate cells and a third cell for the result — no add-ins, no add-ons, and no special setup. You can type this formula in desktop Excel, Excel for the web, and Google Sheets; menu labels may differ slightly by version and region, but the function itself works the same everywhere.
What You'll Need
- Two valid date values in separate cells — for example A2 (start) and B2 (end). These must be entered as dates, not as text like "January 2026".
- A blank cell to hold the formula result.
- Access to Excel (desktop, Microsoft 365, or Excel for the web) or Google Sheets. Any version that supports standard date functions will do.
- Optionally, a helper cell if you want to filter or sort by the result later.
Step-by-Step
- Confirm your dates are real dates. Click each cell and look at the formula bar. If the formula bar shows the date the way you’d read it (like 45323 is wrong, but 15/01/2026 or 01/15/2026 is right), you’re fine. If a cell holds text, the formula will return an error. To convert text to a date, retype it in a format your locale recognises, or use Data > Text to Columns on desktop Excel and choose a date format.
- Pick your start and end cells. Decide which one comes first chronologically. For a tenure calculation, the start is the date someone joined and the end is today or a leaving date. Write these references down — say A2 and B2 — so your formula is consistent down the column.
- Type the base formula. In an empty cell enter
=DATEDIF(A2,B2,"m")and press Enter. The result is the number of whole months that have elapsed from the start date to the end date. For example, from 10 January to 9 February the result is 0 (a full month hasn’t completed), while 10 January to 10 February returns 1. - Decide whether you want partial months counted. If you want a rounded figure where any portion of a month counts, wrap the result in a rounding function or use a year-month-day calculation. A simple approach is
=ROUND(DAYS(B2,A2)/30.44,0), where 30.44 is the average days in a month across a year. This gives an approximation, not an exact calendar count, so use it for estimates only. - Show years and months together. Use
=DATEDIF(A2,B2,"y")&" years, "&DATEDIF(A2,B2,"ym")&" months". The"ym"argument returns the leftover months after whole years are removed, which is exactly the number you want in that sentence. Never use"m"for the second part, or you’ll get the total months instead of the remainder. - Calculate from a start date to today. If the end date is the current date, replace B2 with TODAY():
=DATEDIF(A2,TODAY(),"m"). This updates each time the sheet recalculates, so it’s ideal for tracking how long something has been running. Note that TODAY() returns the date set on the device, so check the machine’s clock if the number looks wrong. - Copy down the column. Drag the fill handle from the bottom-right of the formula cell down the rows. Ensure the references stay relative (A2, B2 rather than $A$2, $B$2) unless you want a fixed comparison against one master date.
- Format the result cell. DATEDIF returns a plain number, so format the cell as a number with no decimals. If you’ve built the year-and-month text version, format it as text — applying a number format to a text string won’t change anything.
- Sanity-check with a reverse example. Enter an end date earlier than the start date. DATEDIF returns #NUM! because it expects the start to be on or before the end. Use this as a quick test that your references are the right way round.
Common Mistakes
Dates stored as text. This is the most frequent cause of errors. A date that looks right on screen but sits in the formula bar as plain text will break DATEDIF. Retype it or convert the column properly.
Swapping start and end. DATEDIF doesn’t handle an end date before the start; it errors rather than returning a negative number. If you genuinely need a signed difference, use (YEAR(B2)-YEAR(A2))*12+MONTH(B2)-MONTH(A2) and check the sign yourself.
Using "m" twice in the year-month formula. The second argument must be "ym" to get the remainder. Mixing them up produces a nonsense total that can exceed 12.
Assuming DATEDIF has autocomplete. It is a legacy compatibility function: Excel will calculate it but won’t suggest it as you type, and its arguments aren’t shown in the usual tooltip. Type the full name and both commas carefully.
Forgetting that a "month" is calendar-based, not 30 days. The formula counts completed calendar months, so months with 31 days behave differently from February. Don’t expect a flat 30.44 days per month from DATEDIF.
Tips
Name your ranges (select the cells, then use the name box) if you’ll reference the same start date in many formulas; it makes the sheets easier to audit later.
Use "md" and "yd" with DATEDIF to get leftover days after months or years, which is handy for precise age or tenure statements.
In Google Sheets, DATEDIF works identically, but the error text may read differently. The logic and argument order are unchanged.
If you need a count of working months excluding partial ones, combine DATEDIF with EOMONTH to snap both dates to month ends first.
Troubleshooting
#NUM! error: your end date is earlier than the start date, or one of the cells is empty. Check both references and that the start truly precedes the end.
#VALUE! error: a date is stored as text or contains stray spaces. Clean the cell and re-enter it as a date.
Result is zero when you expected one: the month hasn’t fully elapsed yet. From the 10th to the 9th of the next month is 0 whole months. If that’s not what you want, switch to the rounded approximation or add a day-boundary check.
Formula works in one row but not below: relative references likely shifted or a cell contains text. Inspect each row’s formula in the formula bar.
Numbers look like dates: the result cell inherited a date format. Apply General or Number format to show the integer.
If that did not work: simplify. Put the two dates in fresh cells and test a minimal =B2-A2. If that returns a number, the dates are valid and DATEDIF should work; if it errors, the problem is in your source data, not the formula.
Frequently Asked Questions
Does DATEDIF exist in Google Sheets?
Yes. The syntax is the same: =DATEDIF(start, end, "m").
Why doesn’t Excel autocomplete DATEDIF?
It is kept for compatibility with older spreadsheets, so it calculates fine but doesn’t appear in the autocomplete list. Type it in full.
Can I count months including the start month?
DATEDIF counts completed months. If you want the start month counted as one, add 1: =DATEDIF(A2,B2,"m")+1.
How do I get an exact number of months and days?
Use =DATEDIF(A2,B2,"m")&" months, "&DATEDIF(A2,B2,"md")&" days".
What if my dates are in different formats?
Format both cells to the same regional date format; the underlying value is the same, but inconsistent display can mislead you when checking.
Is there a simpler alternative to DATEDIF?
For total months, the arithmetic version =(YEAR(B2)-YEAR(A2))*12+MONTH(B2)-MONTH(A2) works but doesn’t account for day-of-month completion the way DATEDIF does.