Skip to content

Instantly share code, notes, and snippets.

@ncalm
Last active June 15, 2023 09:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ncalm/b46398e5ae43ecdd8cfa38cb182eb60b to your computer and use it in GitHub Desktop.
Save ncalm/b46398e5ae43ecdd8cfa38cb182eb60b to your computer and use it in GitHub Desktop.
This Excel lambda function returns TRUE for a leap year and FALSE for all other years
/*
ISLEAPYEAR
Calculates whether a year is a leap year
Inputs:
- yr is the year you want to test
Returns:
TRUE if the year is a leap year, FALSE otherwise
Notes:
Per the documentation, Excel includes a bug that treats 1900 as a leap year.
https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year
*/
ISLEAPYEAR =LAMBDA(yr,
(
(yr<>1900)
*(MONTH(DATE(yr,2,29))=2)
)=1
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment