Professional Documents
Culture Documents
excelunplugged.com/2014/10/28/last-day-of-previous-month-excel
On many occasions we would like to somehow get the dates belonging to the last day of
current, previous or any other month, the first day of this month or any day of the current
month. This post will show you a nice trick how to do that. Whereas for the last dates of the
given month the go to function in Excel would have to be EOMONTH (End Of Month), we will
show a neat trick how to do this with a well-known Excel function called DATE.
First off, let’s say we would like to get the date belonging to the last day of the previous and
the last day of the current month.
EOMNTH
Now with EOMONTH that would go
You can fiddle with the last argument to get to any month between Jan 1900 and Dec 9999.
Keep in mind, that the EOMONTH function gives you only the serial number of the date,
which you then have to format as a date.
1/3
It should be said that the DATE function gives you more leeway than EOMONTH since it can
return literally any day of the month you choose.
=DATE(year,month,day) gives you the date you need or better yet the serial number
belonging to the date you need.
So with DATE function, these would be the two formulas (considering our initial goal)
Now this trick with the zero as the last argument of the date function is genius. But even
better, it can even go into negative. So you can do
=DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())-2) gives you the date of two
days ago.
Here are a few more examples of how you can use both functions
I can already hear you screaming what about the +1 on the month argument of the DATE
function if the current month is December. Well you needless worry about that, you can
easily go over 12 and the DATE function simply returns the month using the remainder after
the number has been divided by 12 and even adds the number of years it get’s from the
division by 12 to the year argument. Simply Brilliant and a great way towards that ever
elusive Eternal Happiness.
2/3
3/3