×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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

 Forum Search FAQs Links MVPs

## Determining Leap Years

(OP)
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.

Thanks.

Larry De Laruelle
larry1de@yahoo.com

### RE: Determining Leap Years

Hi,
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!
Cantor

### RE: Determining Leap Years

(OP)
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
larry1de@yahoo.com

### 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

(OP)
cmmrfrds:

Great idea.

Most often the simple solutions are the best.

Thanks.

Larry De Laruelle
larry1de@yahoo.com

#### 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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!

Already a member? Close this window and log in.