PDA

View Full Version : Solved: How many days in year



Cass
11-14-2005, 06:10 AM
Hei.

How to calculate how many days is in the year. 365 or 366 ?!
:doh:

Tommy
11-14-2005, 07:16 AM
Private Function GiveNumDaysInYear(Year As Long) As Integer
GiveNumDaysInYear = IIf(Year Mod 4, 365, 366)
End Function

TonyJollans
11-14-2005, 10:12 AM
Hi Cass,

Tommy's solution isn't quite complete as it doesn't cater for 'century years'. This should give the right answer for all yearsFunction DaysInYear(Year As Long) As Long
DaysInYear = 365 - (Year Mod 4 = 0) + (Year Mod 100 = 0) - (Year Mod 400 = 0)
End Function