Determining A Leap Year

Results 1 to 4 of 4

Thread: Determining A Leap Year

  1. #1
    Morebyte Guest

    Default Determining A Leap Year

    Does anyone know of a function to easily determine if a year is a leap year or not?

  2. #2
    Mike Shaffer Guest

    Default RE: Determining A Leap Year

    There are all sorts of formulas (Zeller's congruence, etc.), but the simplest way in VB/VBScript is a kludgy trick. Simply build the date for the year you want (e.g. 2/29/xxxx when xxxx is the year) and do an ISDATE function on it. Simple, yes? If xxxx is not a leap year, ISDATE will return false.

  3. #3
    Steve Cimino Guest

    Default RE: Determining A Leap Year

    Sneaky!<BR><BR>And of course, I couldn&#039;t take your word for it... I went ahead and tested it ;)<BR><BR>Public Function checkLeapYear(ByVal dYear as Date) As Boolean<BR> checkLeapYear = IsDate("2/29/" & dYear)<BR>End Function<BR><BR><BR>Neat little function, and simple at that.

  4. #4
    Morebyte Guest

    Default RE: Determining A Leap Year

    Thanks, that really helped.<BR><BR>I had several nested ifs checking the modulas of the year divided by 4, 100, and 1000.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts