Forum Discussion
Show feb 29th in leap years
- Oct 04, 2019
If I understood you correctly your data is like this
In B6 you may use
=IF((MONTH(DATE($K$2,MONTH(1&LEFT($M$2,3)),ROW()-ROW($B$5)))=MONTH(1&LEFT($M$2,3))),ROW()-ROW($B$5),"")and drag it down till B36. It works for any correct combination of year and month in K2 and M2 and skips 29, 30, 31 if there are no such days in year and month.
SergeiBaklan It works! You're my hero.
Can you help me understand how this formula works?
You make use of the row numbers, but I don't understand the month(1&left(M2;3 part
Excel automatically converts date & month combination into the date for the current year. If we take DATEVALUE() which converts text to date with
=DATEVALUE("1February")
or
=DATEVALUE("1Feb")
Excel converts above into the date, 01st February 2019 (2019 is the current year).
If wrap above with MONTH as
=MONTH(DATEVALUE("1February"))
result will be 2 (second month of the year). But with such wrapping we may skip DATEVALUE(), conversion will be applied automatically under the MONTH(). And I'd prefer to use 3 first letters for month's names to reduce the risk of the misprints. Finally
=MONTH("1Feb") returns 2
=MONTH("1Jul") returns 7
etc
- EbbulkOct 04, 2019Copper Contributor
Awesome. Thanks loads!
- SergeiBaklanOct 04, 2019Diamond Contributor
Ebbulk , you are welcome