SOLVED

Leap Year

Copper Contributor

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

13 Replies

@EExmannhotmailcom 

Hello! You've posted your question in the Community Discussion space, which is intended for discussion around the Tech Community website itself, not product questions. I'm moving your question to the Excel space - please post Excel questions here in the future. 

best response confirmed by EExmannhotmailcom (Copper Contributor)
Solution

@EExmannhotmailcom 

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.

@EExmannhotmailcom Another formula could be:

=IF(MOD(YEAR(A1)/4,1)=0,"Leap Year","Not a Leap Year")

 

@Riny_van_Eekelen 

Small comment - that gives incorrect result for every 100, but not every 400 year. For example year 2100 is not leap.

@Sergei Baklan Hmmmm... you are right. Learned something again.

@Eric Starker  Sorry that was not my intend, I'm new here and could not find a solution within Excel (standard formula) to calculate if a date(year) is actualy a leap-year. In my old days as system programmer on main frames there where standard routines you could execute giving it a date and getting back details including if it was in a leap year.

Thanks for your action.

Kind regards, Eddy

@Riny_van_Eekelen I'm getting an error with this formula: "To Few Arguments entered", checked all brackets, checked all arguments as you gave in your example, but keep getting the error. Thanks for your effort.

 

Kind Regards, Eddy

@Sergei Baklan 

 

Will this work if you only have the year??  Thanks!!!

@Mike_Blinn  @Sergei Baklan '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.

@Mike_Blinn , If you only have the year, just remove the Year function in @Sergei Baklan '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, @Sergei Baklan !

Thank you@mtarler  !!

 

Thanks you  @TheAntony  !!

 

@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.

1 best response

Accepted Solutions
best response confirmed by EExmannhotmailcom (Copper Contributor)
Solution

@EExmannhotmailcom 

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.

View solution in original post