Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Determining Leap Years

Determining Leap Years

Determining Leap Years

Does anyone have code that determines whether a year is a leap year?

I'm setting up Forms to control report generation that can span years from 1993 to the present. I would like to test the year to determine if it a leap year in order to set the February end to 2/29/XX.  

I know that leap years when divided by 4 result in a whole number.  Is that all there is to it -- test for a remainder?  I thought I remembered hearing that there were some years that didn't comform to that formula.


Larry De Laruelle

RE: Determining Leap Years

you're right with your rule of the year divided by 4. But I found this on the microsoft site:

"every 100th year is not a leap year—even though it’s divisible by 4—unless it’s also divisible by 400"

Good luck!

RE: Determining Leap Years

Thanks Cantor, I think that is what I was remembering.

Since 2000 is divisible by both 4 and 400 it would seem that I don't have to worry about the second part until the year 2100.  At that point, I don't think I'll care too much.

Thanks again.

Larry De Laruelle

RE: Determining Leap Years

If you are just looking to set the correct month end day in February, then set your date to 3/1/xx and subtract 1. This should work for any month end.

RE: Determining Leap Years


Great idea.

Most often the simple solutions are the best.


Larry De Laruelle

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close