Excel Formula: Count Months Between Two Dates
In this tutorial, it provides formulas to count months between two given dates.
If you want to follow along with this tutorial, please download the example spreadsheet.
Get number of complete months between dates
Generic formula:
DATEDIF(start_date,end_date,”M”) |
Syntaxt and Arguments
Start_date, end_date: the two dates that you want to get months difference between. |
Return Value
The formula returns a whole numeric value that indicates the number of months.
Error Value
1 While the start_date is greater than the end_date, the formula returns an error value #NUM!
2 While the start_date or end_date is not valid dates (a text value or not a valid date in Excel such as dates before 1/1/1900), the formula returns an error value #VALUE!
How this formula works
To count the number of months between dates in cell B3 and C3, please use below formula:
=DATEDIF(B3,C3,"M") |
Press Enter key and drag fill handle over the cells that need this formula.
Explanation
DATEDIF function: returns the number of complete years, months or days between dates.
Remark
The formula calculates and round the number of months down, if you want to get the nearest whole month, you can use the formula as this:
DATEDIF(start_date,end_date+15,"M") |
Get number of decimal months between dates
Generic Formula
YEARFRAC(date1,date2)*12 |
Syntax and Arguments
Date1, date2: the two dates that you count the number of months based on. |
Return Value
The formula returns a value in date format, and you need to format the result as number.
How the formula works
To count the months between the dates in cell B3 and C3, please use the formula as this:
=YEARFRAC(C3,B3)*12 |
Press Enter key then drag fill handle down to the cells for applying this formula.
Keep the formula result selected, and press Ctrl + 1 to display the Format Cells dialog, then under Number tab, click Date from the Category list, choose the date type you want to display in the Type section.
Click OK, the result is shown as date.
Explanation
YEARFRAC function: calculates the fractional year in a decimal format between given dates. Basic formula is YEARFRAC(date1,date2), to multiply 12 at the end of the formula, will get the fractional months in a decimal format between dates.
Remark
If you want to get the whole number of months by the YEARFRAC function, you can add the INT function in the front of the YEARFRAC function like this:
INT(YEARFRAC(date1,date2)*12) |
It counts month rounded down.
Relative Formulas
- Get first day or last day by month text name
Let’s say there is a table containing the year and the month text name for you to get the first day of the month, which formula can you use in Excel? - Count days until expiration date
To count the days between today and each expiration date in Excel by formula - Display current date or time
This tutorial provides formulas to show the current date or time in Excel. - Create weekly date range
In this tutorial, it provides a formula to quickly get the weekly date range in Excel.
Relative Functions
- Excel WEEKNUM Function
Returns the week number of the given date in a year - Excel WORKDAY Function
Adds workdays to the given start date and returns a workday - Excel MONTH Function
The MONTH is used to get the month as integer number (1 to 12) from date - Excel DAY Function
DAY function gets the day as a number (1 to 31) from a date - Excel NOW Function
Get the current time and date
The Best Office Productivity Tools
Kutools for Excel - Helps You To Stand Out From Crowd
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.
