Subtracting or adding months to any date and returning the last day of the month can be done in Excel by using the EOMONTH function. This function is especially useful when determining maturity or due dates. This tutorial will assist all levels of Excel users in the usage and syntax of EOMONTH function.
Figure 1. Final result: Excel EOMONTH function
Syntax of EOMONTH Function
EOMONTH adds or subtracts a certain number of months before or after a specified date and returns a date falling on the last day of the month
- start_date – a date representing the start date; can be a date enclosed in quotation marks or a cell reference
- months – the number of months either before or after the start date; a positive value results to a future date while a negative value results to a past date
- If months is not an integer, the truncated value is used by the function
- The date must be between January 1, 1900 and December 31, 9999
- If start_date is not a valid date, EOMONTH returns the #VALUE! error value
Setting up our Data
Our table contains three columns: Start Date (column B), Months (column C) and Result (column D). We want to add or subtract the number of months in column C from the start date in column B and return the last day of the resulting date. The results will be recorded in column D.
Figure 2. Sample data for Excel EOMONTH function
Determine last day of resulting date using EOMONTH
We want to determine the last day of the resulting dates by using the EOMONTH function. Let us follow these steps:
Step 1. Select cell D3
Step 2. Enter the formula:
Step 3. Press ENTER
Step 4: Copy the formula in cell D3 to cells D4:D9 by clicking the “+” icon at the bottom-right corner of cell D3 and dragging it down
Figure 3. Entering the formula using the EOMONTH function
February 2019 is one month from the start date of “1/27/2019”. Hence, our EOMONTH function returns the date “2/28/2019” in cell D3, which is the last day of February 2019. Note that EOMONTH function returns valid dates, and adjusts the month, day and year accordingly.
For the next example, the number of months is 2.5, which is not an integer. EOMONTH truncates this value and interprets the number of months as 2. As a result, the date in cell D4 is “3/31/2019”, which is two months from our start date, and falling on the last day of the month of March.
Figure 4. EOMONTH truncates non-integer values for months
The same principle is shown in the next example where the number of months is zero. Our formula returns the same month as the start date, but falling on the last day. As a result, the value in D5 is “1/31/2019”.
Figure 5. EOMONTH returns last day of the same month
The EOMONTH function also handles negative values for the number of months, as shown in the next examples. The value -1 means one month before the start date, while -2.5 is truncated to -2 and refers to two months before the start date.
Finally, our formula returns “3/31/2019” and “2/28/2019” in cells D6 and D7. Both of which fall on the last day of their respective months.
Figure 6. EOMONTH returns past dates for negative values of months
The EOMONTH function returns the error #VALUE! when the start date is invalid. In cell B8, the date “1/27/1890” is not valid because the function only allows dates between January 1, 1900 and December 31, 9999.
Cell B9 is also invalid because “2/29/2019” does not exist. The last day of the month of February 2019 is 28, not 29.
Figure 7. EOMONTH returns an error for invalid start dates
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.