Sometimes you need to know how to get the last day in a given month. Maybe to set a date when an invoice is due or when you need to have a task completed. Excel has a function to let you do this.
That function is =EOMONTH
Let’s say we want to get the last day of the current month. Today’s date is 5/12/2015. You would use the formula
The current date is in A2 above. So our formula in B2 is =EOMONTH(A2,0)
What this does is look at A2, which is 5/12/2015 and returns the last day in that month.
The 0 in the formula just means Excel looks at the current month, which is May. So that is why it returns 5/31/15
Now if we wanted to know the last day of the month before, we would use the formula =EOMONTH(A2,-1)
See, we just changed the 0 to -1, which means it looks at the month before, which is April:
If we wanted to know 2 months in advance, then =EOMONTH(A2,2) would be our formula.