Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining Leap Years

Status
Not open for further replies.

LarryDeLaruelle

Technical User
May 19, 2000
1,055
0
0
US
Does anyone have code that determines whether a year is a leap year?<br><br>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.&nbsp;&nbsp;<br><br>I know that leap years when divided by 4 result in a whole number.&nbsp;&nbsp;Is that all there is to it -- test for a remainder?&nbsp;&nbsp;I thought I remembered hearing that there were some years that didn't comform to that formula.<br><br>Thanks. <p>Larry De Laruelle<br><a href=mailto:larry1de@yahoo.com>larry1de@yahoo.com</a><br><a href= > </a><br>
 
Hi,<br>you're right with your rule of the year divided by 4. But I found this on the microsoft site:<br><br>&quot;every 100th year is not a leap year—even though it’s divisible by 4—unless it’s also divisible by 400&quot;<br><br>Good luck!<br>Cantor
 
Thanks Cantor, I think that is what I was remembering.<br><br>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.&nbsp;&nbsp;At that point, I don't think I'll care too much.<br><br>Thanks again. <p>Larry De Laruelle<br><a href=mailto:larry1de@yahoo.com>larry1de@yahoo.com</a><br><a href= > </a><br>
 
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.
 
cmmrfrds:<br><br>Great idea.<br><br>Most often the simple solutions are the best.<br><br>Thanks. <p>Larry De Laruelle<br><a href=mailto:larry1de@yahoo.com>larry1de@yahoo.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top