Leap Year in Google Sheets

Learn how to determine if a year is a leap year in Google Sheets using clever formulas and Apps Script. This video covers practical methods to identify leap years, which can be essential for financial and HR applications.

There's some pretty clever ways to find out if it's a leap year or not. Why does this matter is because sometimes in financial transactions, bookkeeping, any kind of HR, salary wise, we want to know, is this year a leap year? Is there a 29th of February or not? And I want to share with few ways that we can figure this out. So we have some years here and we want to know, are they a leap year? Well, if you're not familiar with the Gregorian calendar and how to determine a leap year, we could actually use the date function to figure this out. We can say the date is 2020 and here for year, we could use the number 2020, or we could reference this cell. And then we can say month 2, day 29. Ben Asks: How Do I Add 1 Month? How Many Days This Year? Google Sheets Formula

And if this turns out to actually be the 29th of February, it is a leap year. So if we copy paste this, we'll see that becomes March for non leap year years. So how do we know if it's March or February? Well, we can wrap this with month. And now, let's copy paste this, we have 2, if it's a leap year, and if it's not a leap year, we have the number 3. So we can use this in an if, if it's equal to 2, that's true, leap year. And if it's false, not leap year. And that's an interesting way to figure it out, right? But we do have a pretty definitive way, if you do know the Gregorian calendar, we can do this in Apps Script . Building a Year Progress Clone How Many Days This Year? Google Sheets Formula

We can create a function called leap year. Put in a variable here, year, that we're going to insert in the sheet itself. And all we need to do is return the answer, true or false, of something pretty simple. Take the year, divide it by 4, and if there's a remainder, then it's not a leap year. We also have to consider that year could be divided by 100 and it's not equal to zero. We're going to wrap this all around and add one more thing or year divided by 400 is equal to zero. And so now with this, let's save it and add one more thing up here. What I like to do is slash. Big Year Updated with PILLAR Template 80 Years In 1 Spreadsheet How Many Days This Year? Google Sheets Formula

Asterix at custom function . Why is that? It's because if we go here and we say, is it a leap year? Leap year shows up. This is a function that we just created called leap year can even make it all caps leap year. Save that equals leap year. There we go. Leap year 2020. And is it going to come back true or false, true if that's 2020, but if we reference here, we get false. If it's not a leap year and true, if it is a leap year, and that's from this custom function that we can create right there in app script and add this at custom function that allows us to use this in a Google sheet. Isn't that cool? So I gave you a couple of options. What is this Ampersand Doing in Google Sheets? Turn Your Apps Scripts into Native Formulas | Apps Script Custom Function Tutorial EASY How Many Days This Year? Google Sheets Formula

We got this month, day, February 29th, and an app script to figure out if it's a leap year or not. If you're enjoying this and you want more automations, more cool stuff to add to your Google Sheets, subscribe to BetterSheets here on YouTube right now. Get Sheets Wrapped 2024 | Your Year in Google Sheets This Week in Better Sheets - Feb 12th, 2023 Big Year How Many Days This Year? Google Sheets Formula