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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me with counting days 1

Status
Not open for further replies.

icul

IS-IT--Management
Nov 9, 2000
2
US
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

Code:
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
 
[tt]
FUNCTION isLeap%(year%)
IF (year% MOD 100) = 0 THEN
isLeap% = ((year% MOD 400) = 0)
ELSE
isLeap% = ((year% MOD 4) = 0)
END IF
END FUNCTION
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top