Proving Leap Year is NOT Every Four Years with PowerShell

Last week, I saw a couple of tweets from PowerShell MVP Jeffery Hicks about leap year that caught my attention:


One of the reasons that I found those tweets so interesting is that I had just heard the night before on of all places, Wheel of Fortune, that leap year wasn’t every four years. I’d always been told that leap year was every four years and it has been for my entire life so it was time to investigate further.

I decided to start with one of Jeff’s examples and add some code to it to determine which years should be leap years but weren’t based on the popular belief that leap year is every four years:


Now that’s interesting. Why aren’t those years, shown in the previous example, leap years? I found a Wikipedia article about leap year with the answer to that question which I documented in the description section of the comments in the function shown in the following example. That Wikipedia article also provided some pseudo-code which I converted into PowerShell:


As you can see 1900 was not a leap year and there were 8 years between leap years from 1896 to 1904. Eight years between leap years won’t occur again until years 2096 to 2104 .



  1. Greg Wojan

    Use the Framework Luke… 😉

    1890..1910 | % { “Leap year ($_): $([DateTime]::IsLeapYear($_))” }

  2. Greg Wojan

    Actually, I guess I should have paid more attention to Jeff’s second tweet… 🙁 Sigh.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: