Excel’s EOMONTH function is great. Here is a tweak using a custom function to calculate the number of days in a month.
Custom functions are new – below is a link to an earlier blog post explaining and demonstrating a custom function.
Days in the month
How many days in the month? This is usually calculated with a formula like.
=DAY(EOMONTH(A1,0))
Let’s simplify it to this.
=fnEOMDAY(A1)
The LAMBDA function that you can save as a custom function is this.
=LAMBDA(d,DAY(EOMONTH(d,0)))
This works on the current month of the date used. Any date will return the number of days in the month.
The New Name dialog creating this Custom Function is shown below.
The formulas used are in the image below. The formulas are in column B but are shown in column C.
In the next blog post and I will cover returning the last weekday date of the month.
Please note: I reserve the right to delete comments that are offensive or off-topic.