×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

(OP)
I need help to count the days in certain month and certain year (whether it's a leap year or not). Actually I just need the formula to find out if the year is a leap year or not.

Thanks

Hi,
***divisible  means evenly divisible(no remainder)

The century years (1800, 1900,2000) must be divisible by four hundred.
All the other years must be divisible by four.

Check if divisible by 100(a century)
yes
Check if divisible by 400
yes
it's a leap year
no
its not
no
check if divisible by 4
yes
it's a leap year
no
its not

That's a little more than the formula but it's not the code.
Good Luck,
Pappy

Or you may use an Error handling routine to find how many days in that year's February...
force system time to set to 29th of february like

DATE\$ = "02/29/2001"

if systems gives te error "ILLEGAL FUNCTION CALL" you understand that this year is not a Leap Year...
Even you may design a FUNCTION that controls if given year is leap or not (but if you design a Function don't forget to use LOCAL in error handling like "ON LOCAL ERROR GOTO xxx"

If you're interested i may write you a simple code..
Good luck

FUNCTION isLeap%(year%)
IF (year% MOD 100) = 0 THEN
isLeap% = ((year% MOD 400) = 0)
ELSE
isLeap% = ((year% MOD 4) = 0)
END IF
END FUNCTION

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

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!