Forum Discussion
EExmannhotmailcom
May 23, 2020Copper Contributor
Leap Year
Finaly got a working routine in Excel VBA to calculate if current or specific date is in a leap year. Please send me a note and I will publish the VBA code in English. kind regards, Eddy
- May 27, 2020
Just in case, with formula you may check as
=IF(MONTH(DATE(YEAR(A1),2,29))=2,"leap", "not leap") or =IF(DAY(DATE(YEAR(A1),3,0))=29,"leap", "not leap") or likeif the date is in A1.
SergeiBaklan
May 27, 2020Diamond Contributor
Just in case, with formula you may check as
=IF(MONTH(DATE(YEAR(A1),2,29))=2,"leap", "not leap")
or
=IF(DAY(DATE(YEAR(A1),3,0))=29,"leap", "not leap")
or like
if the date is in A1.
- Mike_BlinnJul 28, 2020Copper Contributor
- TheAntonyJul 28, 2020Iron Contributor
Mike_Blinn , If you only have the year, just remove the Year function in SergeiBaklan 's formulas:
=IF(MONTH(DATE(A1,2,29))=2,"leap", "not leap")=IF(DAY(DATE(A1,3,0))=29,"leap", "not leap")Love the simplicity and elegance of the formulas, SergeiBaklan !
- Mike_BlinnJul 29, 2020Copper Contributor
Thanks you TheAntony !!
- mtarlerJul 28, 2020Silver Contributor
Mike_Blinn SergeiBaklan 's formula will work for any date in that year. If you are going to pass only a number (e.g.. 2020) then you could use:
=IF(MONTH(DATE(A1,2,29))=2,"leap","no leap")again where cell A1 has the year number you are asking about.
- EExmannhotmailcomJul 29, 2020Copper Contributor
mtarler I Think that is correct, since January 1st of March 1st or any day in that given year will of will-not be in part of a Leap Year.