The MONTH function displays the month portion of a date that has been entered into the function. A typical use for the function is to subtract dates in Excel that occur in the same year.
The syntax for the MONTH function is:
= MONTH ( Serial_number )
Example: Subtract Dates with the MONTH Function
For help with this formula see the image above.
In the example below we will find the number of months between two dates. Since the function excludes the year portion of a date, it will not correctly calculate the number of months between two dates that are in different years.
Our final formula will look like this:
= MONTH ( D1 ) - MONTH ( D2 )
To enter the formula into Excel we have two options:
- Type the above formula in to cell E1 with the two dates to be subtracted in cells D1 and D2
- Use the MONTH function dialog box to enter the formula into cell E1
- Enter the following dates into the appropriate cells
- Click on cell E1 - the location where the results will be displayed.
- Click on the Formulas tab.
- Choose Date & Time from the ribbon to open the function drop down list.
- Click on MONTH in the list to bring up the function's dialog box.
- Click on cell D1 to enter the cell reference of the first date into the dialog box.
- Click OK.
- In the formula bar you should see the first function: = MONTH ( D1 ).
- Click in the formula bar after the first function.
- Type a minus sign ( - ) into the formula bar after the first function since we want to subtract the two dates.
- Choose Date & Time from the ribbon to open the function drop down list again.
- Click on MONTH in the list to bring up the function's dialog box a second time.
- Click on cell D2 to enter the cell reference for the second date.
- Click OK.
- The number 7 should appear in cell E1 as there are 7 months between May 2009 and December 2009.
- When you click on cell E1 the complete function = MONTH ( D1 ) - MONTH ( D2 ) appears in the formula bar above the worksheet.