Excel Office

Excel How Tos, Tutorials, Tips & Tricks, Shortcuts

Get last day of month in Excel

If you want to calculate the last day of a month based on a given date, then this tutorials is for you.

The example below shows two different ways to achieve this.

First, use the EOMONTH function.

Formula

=EOMONTH(date,0)

Explanation

In the example shown, the formula in cell B5 is:

=EOMONTH(B5,0)

The 2nd argument (months) of the EOMONTH function allows you to get the last day of the month in future or past months. When you use zero for months, EOMONTH will return the last day of the month in the same month.

Worked Example:   Steps to create Dynamic calendar grid in Excel

To get the last day of the prior month, use:

=EOMONTH(date,-1)

To get the last day of the next month, use:

=EOMONTH(date,1)

Although EOMONTH is a more convenient function, it won’t accept a range of dates in an array formula. In that case, you can also use the alternative below.

Worked Example:   Average by month in Excel

 Alternative formula

You can also write a formula using the DATE, YEAR and MONTH functions to return the last day of the month:

=DATE(YEAR(date),MONTH(date)+1,0)

The trick with this formula is supplying zero for the day. When you supply zero as the day argument to DATE, the date function will “roll back” one day to the last day of the previous month. So, by adding 1 to the month, and using zero for day, DATE returns the last day of the “original” month.

Worked Example:   Calculate expiration date in Excel

 

Leave a Reply

Your email address will not be published. Required fields are marked *