# How to calculate the number of months between two dates in Excel

Use `=DATEDIF(start, end, "m")`. It counts complete months, so a month only counts once the same day of the month comes around again.

**Excel:** `=DATEDIF(B2,C2,"m")` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D |
| --- | --- | --- | --- |
| Customer | Signed up | Cancelled | Months |
| Harbor Bakery | 2024-03-15 | 2026-01-14 |  |
| Pine Dental | 2025-06-01 | 2026-06-01 |  |
| Ortiz Law | 2025-01-31 | 2025-02-28 |  |
| Bluebird Yoga | 2025-09-10 | 2026-04-22 |  |
| Kline Auto | 2023-11-20 | 2026-02-19 |  |

Formula in D2, filled to D6: `=DATEDIF(B2,C2,"m")`

Result: 21; 12; 0; 7; 26

## How it works

DATEDIF with `"m"` counts whole months between the two dates. Harbor Bakery signed up on the 15th and cancelled on the 14th, 22 calendar months later, so the last month isn't complete and the answer is 21. Ortiz Law ran from January 31 to February 28, which isn't a full month, so it shows 0.

## Other ways

- `=(YEAR(C2)-YEAR(B2))*12+MONTH(C2)-MONTH(B2)`: Counts calendar months crossed and ignores the day. Use it when any part of a month counts, as in monthly billing. (Ignores the day of the month: January 31 to February 28 is 1.)
- `=ROUND((C2-B2)/(365.25/12),1)`: Approximate months with a decimal, for averages and charts. (Decimal months.)

## Common mistakes

- DATEDIF returns #NUM! when the start date is after the end date. Swap them, or use MIN and MAX to put them in order.
- Dividing the days by 30 drifts: 365 days come out as 12.2 months. Use DATEDIF for whole months.
- DATEDIF isn't in Excel's autocomplete, so type it in full. It works in every version and in Google Sheets.

## Questions

**How do I get months and leftover days?**

`=DATEDIF(B2,C2,"m")&" months, "&DATEDIF(B2,C2,"md")&" days"`.

**How do I count the months until today?**

Use a cell with `=TODAY()` as the end date, like `=DATEDIF(B2,F1,"m")`.

**How do I get whole years instead?**

Use `"y"`: `=DATEDIF(B2,C2,"y")`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/months-between-two-dates
