SDU Tools: Determining Leap Years in T-SQL with IsLeapYear

Is 2018 be a leap year?

Was 2000 a leap year?

Will 2100 be a leap year?

When I was a young student at school, we learned that leap years were every four years. Then as I got older, I learned that there was more to it than that.

It's important to understand that any calendar is just an approximation, and there is a lot more to calendars than most people realize.

For those that would really like to get some background, my favorite calendar-related site is Claus Tøndering's Calendar FAQ. It's a wonderful collection of details of calendars and their history. In addition, for those that are into coding, he has sample program code to determine things like when is Easter next year?

Currently the rule for determining leap years is:

  • Every fourth year
  • Except if the year is divisible by 100 but not by 400

So, to answer the questions above, 2018 is not a leap year, 2000 was a leap year, but 2100 is not a leap year. (It's the last one that usually surprises people).

Apparently the scientists are still discussing where or not there should be a 4000 year rule. Can't say that I care as I won't be here.

We added a simple tool to do these calculations:

You can see it in action here:

For more information on our free SDU Tools, please visit:

http://sqldownunder.com/sdu-tools

 

 

 

 

Leave a Reply

Your email address will not be published.