Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
This article describes the formula syntax and usage of the EOMONTH function in Microsoft Excel.
Description
Returns the serial number for the last day of the month that is the indicated number of months before or after start_date. Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.
Syntax
EOMONTH(start_date, months)
The EOMONTH function syntax has the following arguments:
-
Start_date Required. A date that represents the starting date. Dates should be entered by using the DATE function, or as results of other formulas or functions. For example, use DATE(2008,5,23) for the 23rd day of May, 2008. Problems can occur if dates are entered as text.
-
Months Required. The number of months before or after start_date. A positive value for months yields a future date; a negative value yields a past date.
Note: If months is not an integer, it is truncated.
Remarks
-
Microsoft Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900.
-
If start_date is not a valid date, EOMONTH returns the #NUM! error value.
-
If start_date plus months yields an invalid date, EOMONTH returns the #NUM! error value.
Example
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.
Date |
||
1-Jan-11 |
||
Formula |
Description |
Result |
=EOMONTH(A2,1) |
Date of the last day of the month, one month after the date in A2. |
2/28/2011 |
=EOMONTH(A2,-3) |
Date of the last day of the month, three months before the date in A2. |
10/31/2010 |
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
Sometimes we need to get an end-of-month date to use as a completion date, a due date, as a target date, or sometimes we need it to calculate the days between two dates.
Without any effort, we can easily add it manually, but there are some formulas that can help us to calculate it.
The best way to calculate the last date of the month is by using the EOMONTH Function. But apart from this, you can also use other methods (VBA).
Using a formula or any other dynamic method has the benefit that we don’t need to calculate it again and again. Today, in this post, I’d like to share with you 3 simple and dynamic ways to get the end of the month date in Excel.
So let’s get started and please download this same file from here to follow along.
Get the Last Day of the Month using EOMONTH Function
EOMONTH is my favorite function to calculate the last day of a month. This function is specifically designed for these kinds of calculations.
All you have to do is just specify a date current date, and the number of months you want to calculate the last date before and after the start date. Here is the syntax:
EOMONTH(start_date,months)
In this syntax, the start date will be the current date and months will be a number that represents the number of months forward or backward.
Let’s say, you have the date “06-Feb-2017” and you want to get the last day of “Feb”. In this case, the formulas you need to use are:
=EOMONTH("22-Feb-2017",0)
In the above example, when you use EOMONTH, has returned 28-Feb-2017 which is the last date of the Feb month.
How does it work: Here, you have used “0” for the number argument because the start date you have used is of Feb month and you won’t have the last day of the same month. When you use “0” it will simply return the last date for the same month for which you have the start date.
To create a dynamic formula you can use the TODAY Function in the start_date
argument.
End Date of the Future Month
Now, let’s say, from the same date you want to get the last day of “Apr”. In this case, the formulas you need to use are:
=EOMONTH("22-Feb-2017",2)
In the above example, the formula has returned 30-Apr-2017 which is the last date of the Apr month.
How does it work
Here, you have used “2” for the number argument and the start date you have used is of Feb month. Now, if you look, Apr is exactly 2 months after Feb so that’s why it has returned 30-Apr-2017.
End Date of the Previous Month
And, if you want to get the last date of a previous month you can use a negative number for that. Let’s say you want the last day of Jan. So, the formula you need to use:
=EOMONTH("22-Feb-2017",-1)
In the above example, the formula has returned 31-Jan-2017 which is the last date of the Jan month.
How does it work: Here, you have used “-1” for the number argument and Jan is exactly 1 month before Feb.
DATE Function to Get Month’s Last Date
DATE Function is another approach to getting the last day in excel. The date function helps you to create a valid excel date by specifying the year, month, and day. Here is the syntax:
DATE(year,month,day)
As I have mentioned, in the date function, you need to enter the year, month, and day, and it returns a valid date according to that. Now, there is a small trick that you can do with day argument.
Quick Trick: If you use 0 asa day it will return the last date of the previous month. For example, if you specify, Year: 2017, Month: 4 (that’s May) and Day: 0 it will return 30-Apr-2017 in the result.
And, if you want to calculate the last day of the current month the formula will be:
=DATE(CurrentYear,CurrentMonth + 1,0)
Or, if you just have a date to refer then the formula will be:
=DATE(YEAR(date),MONTH(date)+1,0)
Get Last Day with a UDF
A great VBA Example. This is a macro code for using a VBA UDF to get the last day of the month. You just need to copy it into your VBA editor.
Function LastD(Optional sd As Date = 0) As Date
If sd = 0 Then
sd = VBA.DateLastD = VBA.DateSerial(VBA.Year(sd), VBA.Month(sd) + 1, 0)
End Function
In your worksheet, type “=LastD(” and insert the date for the month or refer to a cell. And, if you want the last day of the current month then simply left it blank using brackets.
Conclusion
As I said, the month’s last day can be helpful for you while calculating target dates, due dates, or completion dates. And, now we have three different ways to get it.
If you use EOMONTH then it’s really easy to create a dynamic formula that can help you to date for past or future months and I think it’s the best way to do it.
I hope you found it useful and it will help you take your skills to the whole next level.
Now tell me one thing. Which one is your favorite method above all? Or, do you have a different method? Please share with me in the comment box, I would love to hear from you.
And, don’t forget to share it with your friends.
To get the date of the last day of the month in Excel, use the EOMONTH (End of Month) function.
1. The EOMONTH function below returns the last day of the month.
Note: the EOMONTH function returns the serial number of the date. Apply a Date format to display the date.
2. The EOMONTH function below returns the same date. Use the DATE function in Excel to hardcode a date.
Let’s kick it up a notch! Use the second argument of the EOMONTH function to specify a number of months in the future or in the past.
3. The EOMONTH function below returns the last day of the next month.
4. The EOMONTH function below returns the last day of the previous month.
5. The EOMONTH function below returns the last day of the month, 8 months in the past!
Explanation: = 6 — 8 = -2 = October (-2 + 12 = 10) in 2015!
6. Use EOMONTH and TODAY to return the last day of the current month.
Note: today is January 15th, 2022.
7. Finally, to find the first day of the month in Excel, simply use DATE, YEAR and MONTH.
Explanation: the DATE function accepts three arguments: year, month and day. Use YEAR to get the year of a date. Use MONTH to get the month of a date.
In this article, we will learn How to calculate the date at the end of a month in Excel.
Scenario:
At times, we need to know the expiry date of any product given its period of expiry and manufactured date. And you would be thinking why to do it manually. Then YES. You are right. The Excel function does your work here. Let’s understand how excel works with dates to get the end date for the month using the Excel EOMONTH function.
EOMONTH function in Excel
EOMONTH function is used to find the last day of the given month. It requires two things:
- From the date you wish to count or the manufacturing date.
- Number of months from the date or its living period.
EOMONTH function Syntax:
=EOMONTH( Start_date, months)
start_date : a valid date representing the start date for the function.
Months : a positive or negative number to get the date for after or before the start date.
Example :
All of these might be confusing to understand. Let’s understand how to use the function using an example. Here we have start dates in the first columns and period of months in the second column.
Using the formula in the cell where we want the last day of the given month.
Formula:
Here arguments to the function are given as cell reference.
To get the 5 months after the 1st September 2014. What is the last day of that month? The month comes out to be february and the last day of feb 2015 is 28th of Feb.
Copy the formula in other cells, select the cells taking the first cell where the formula is already applied, use the Ctrl + D shortcut key.
As you can see from the above example, you can find the last day of any month using the EOMONTH function.
Sometimes the value returned by the function is a 5 digit number seems like some code digit or something. It’s nothing, As Excel stores date and time values as serial numbers. So just change the format of the cell from General to Date. Or Select the type of date format from Custom Format cell box.
Here are some observational notes using the above function in Excel.
Notes:
- Excel records dates as serial numbers for calculation purposes. So valid date format or else the function returns the #NUM! Error.
- You can add or subtract months to get to the required month and then get the last date of the month.
- The start_date plus the months yields a invaild date, the function returns the #NUM! error.
Hope this article about How to calculate the date at the end of a month in Excel is explanatory. Find more articles on calculating values and related Excel formulas here. If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook. We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write to us at info@exceltip.com.
Related Articles :
Count holidays between dates in Excel : count non working days between the two given dates using the DATEDIF and NETWORKDAYS function in Excel.
SUM price by weekdays in Excel : sum price values corresponding to the number of dates in a particular weekday using the SUMPRODUCT and WEEKDAY function in Excel.
How to Convert date to text in Excel : In this article we learned how to convert text into date, but how do you convert an excel date into text. To convert an excel date into text we have a few techniques.
Extract days between dates ignoring years in Excel : count the days between the two dates using different functions and mathematical operation in Excel
How to Convert date to text in Excel : In this article we learned how to convert text into date, but how do you convert an excel date into text. To convert an excel date into text we have a few techniques.
How to use the WORKDAYS function in Excel : Returns a workday date value after days added to the start_date using the WORKDAYS function in Excel.
Count Birth Dates By Month in Excel : count the number of dates lying in a particular month using the SUMPRODUCT and MONTH function in Excel.
Popular Articles :
50 Excel Shortcuts to Increase Your Productivity : Get faster at your tasks in Excel. These shortcuts will help you increase your work efficiency in Excel.
How to use the VLOOKUP Function in Excel : This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets.
How to use the IF Function in Excel : The IF statement in Excel checks the condition and returns a specific value if the condition is TRUE or returns another specific value if FALSE.
How to use the SUMIF Function in Excel : This is another dashboard essential function. This helps you sum up values on specific conditions.
How to use the COUNTIF Function in Excel : Count values with conditions using this amazing function. You don’t need to filter your data to count specific values. Countif function is essential to prepare your dashboard.
Excel EOMONTH Function
The EOMONTH is a worksheet date function in Excel that calculates the end of the month for the given date by adding a specified number of months to the arguments. This function takes two arguments: one as the date and another as an integer. The output is in date format. The method to use this function is as follows =EOMONTH( start_date, months).
For example, suppose we have data as of 02/04/2020 in column B and the second row. Therefore, the formula will be:
=EOMONTH(B2,
=31/12/2020
Here, to add the last day of December (4+8), the Excel EOMONTH function added 8 and returned the result as 31/12/2020.
Table of contents
- Excel EOMONTH Function
- Formula
- How to Use the EOMONTH Function in Excel? (with Examples)
- Example #1 – 1 month forward
- Example #2 – 6 Months Backward
- Example #3 – The Same Month
- Things to Remember
- EOMONTH in Excel Video
- Recommended Articles
Formula
It has two arguments, out of which both are required. Where,
- start_date = This represents the starting date. We must enter the date by using the DATE function. E.g.: DATE (2018,5,15)
- months = The number of months before or after the start_date. If the number is positive, it indicates the future date. If the number is negative, it yields a date in the past.
The return value of the EOMONTH is a serial number that can further be converted into a user-friendly date format using the DATE function.
How to Use the EOMONTH Function in Excel? (with Examples)
You can download this EOMONTH Function in Excel Template here – EOMONTH Function in Excel Template
Example #1 – 1 month forward
As shown in the above EOMONTH formula,
=EOMONTH (B2,1)
The Excel EOMONTH function is applied to cell B2, a date value of 21st August 2018. The second parameter value is 1, indicating one-month forward, September.
Cell C2 represents the resulting cell wherein the value is 43373, the serial number of the resultant date, i.e., the last day of the month, September 2018. The serial number is further converted into a readable date format using the TEXT function in Excel, which takes the value to be converted and the date format as its parameters.
Here, the value from cell C2 is converted into the date format as ‘dd/mm/yyyy,’ and the resultant date is displayed in cell D2, which is 30th September 2018.
Example #2 – 6 Months Backward
As shown in the below EOMONTH formula,
=EOMONTH (B4, -6)
The EOMONTH function in Excel is applied on cell B4, with a date value of 21st Aug 2018. The second parameter value is -6, which indicates February 6-months backward. Cell C4 represents the result cell wherein the value is 43159, the serial number of the resultant date, the last day of February of 2018.
The serial number is further converted into a readable date format using the TEXT function in Excel, which takes the value to be converted and the date format as its parameters. Here, the value from cell C4 is converted into the date format as ‘dd/mm/yyyy,’ and the resultant date is displayed in cell D4, 28th February 2018.
Example #3 – The Same Month
As shown in the below EOMONTH formula,
=EOMONTH (B6, 0)
The Excel EOMONTH function is applied to cell B6, a date value of 21st August 2018. The second parameter value is 0, which indicates August’s the same month. Cell C6 represents the result cell wherein the value is 43343, the resultant date’s serial number, the last day of August 2018.
The serial number is further converted into a readable date format using the TEXT function in excelTEXT function in excel is a string function used to change a given input to the text provided in a specified number format. It is used when we large data sets from multiple users and the formats are different.read more, which takes the value to be converted and the date format as its parameters. Here, the value from cell C6 is converted into the date format as ‘dd/mm/yyyy,’ and the resultant date is displayed in cell D4, which is 31st Aug. 2018.
Things to Remember
- If the start_date is not a valid date, EOMONTH may return the #NUM! Error in the number.
- If the resultant date, i.e., after adding or deducting the given number of months (the 2nd parameter), is invalid, then EOMONTH returns #NUM! Error in the number.
- If the start_date is written in an un-appropriate format, then the EOMONTH function returns #VALUE! Error in the value.
- The return value of the EOMONTH function Excel is a serial number that can further be converted into a user-friendly date format using the DATE Excel functionThe date function in excel is a date and time function representing the number provided as arguments in a date and time code. The result displayed is in date format, but the arguments are supplied as integers.read more.
- By default, Excel treats January 1, 1900, as serial number 1. And January 1, 2008, as a serial number 39448, indicating it is 39,448 days after January 1, 1900.
EOMONTH in Excel Video
Recommended Articles
This article has been a guide to EOMONTH in Excel. We discuss using EOMONTH in Excel and its formula, practical examples, and a downloadable template. You may also look at these useful functions in Excel: –
- MONTH Function in Excel
- YEAR Function
- NOW In Excel | Examples
- WORKDAY in Excel