Dear all
Could someone explain below formula to me please.
The red parts, no idea.Rich (BB code):=DAY(DATE(YEAR(A1),MONTH(A1)+1,1)-1)
Thank you very much
1. Given a date, the formula constructs first a first day date following the month/year of A1.
A1 = 4/20/2015
==> 5/1/2015
Note that this is DATE applied to 2015, 5 (MONTH of A1, which is 4, plus 1) and 1.
2. Subtracting 1 from the first day date of (1), that is,
5/1/2015 minus 1, we get:
==> 4/30/2015
3) DAY applied to (2), we get:
==> 30
which is days April (of 2015) counts.
Understand it now. Thank you very much.
You are welcome.
Since EOMONTH is directly available in the recent Excel versions...
=DAY(EOMONTH(A1,0))
can also be invoked to the same effect.
Vanda_a, Good morning.
It's a very good explanation about this formula.
Aladin Akyurek, congratulations!
I suggest you to use this formula:
=DAY(EOMONTH(A1),0)
I think it's more simple.
I hope it helps.
Have a nice day.
Alternative to last day of previous month from today:
=DAY(TODAY()-DAY(TODAY()))
or a date in A1
=DAY(A1-DAY(A1))