Exceljet

Quick, clean, and to the point

Get months between dates

Excel formula: Get months between dates
Generic formula 
=DATEDIF(start_date,end_date,"m")
Explanation 

To calculate months between two dates as a whole number, you can use the DATEDIF function.

In the example shown, the formula in D6 is:

=DATEDIF(B6,C6,"m")

Note that the DATEDIF automatically rounds down. To round up to the nearest month, see below.

The mystery of DATEDIF

The DATEDIF function is a "compatibility" function that comes from Lotus 1-2-3. For reasons unknown, DATEDIF is only documented in Excel 2000, and will not appear as a suggested function in the formula bar. However, you can use DATEDIF in all Excel versions since that time, you just need to enter the function manually. Excel will not help you with function arguments. See this page on the DATEDIF function for more information about available arguments.

How this formula works

DATEDIF takes 3 arguments: start date, end_date, and unit. In this case, we want months, so we supply "m" for unit.

DATEDIF automatically calculates and returns a number for months, rounded down.

Nearest whole month

DATEDIF rounds down by default. If you want to calculate months to the nearest whole month, you can make a simple adjustment to the formula:

=DATEDIF(start_date,end_date+15,"m")

This ensures that end dates occurring in the 2nd half of the month are treated like dates in the following month, effectively rounding up the final result.

Author 
Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.