- Home
·
- Math/Dates
·
- This code returns the number of days passed since the given year. The date of year is condsidered f
This code returns the number of days passed since the given year. The date of year is condsidered f
This code returns the number of days passed since the given year. The date of year is condsidered from 1st Jan. Currently the starting year
Rate This code returns the number of days passed since the given year. The date of year is condsidered f
(1(1 Vote))
On Error GoTo Error
Dim lngResult As Long
Dim boolLeap As Boolean
Dim intMonthCnt As Integer
boolLeap = False
lngResult = mintDay
Dim lngNumYears As Long
lngNumYears = mintYear - intFirstYear
lngResult = lngResult + lngNumYears * 365 + Fix((lngNumYears) / 4)
If mintYear Mod 400 = 0 Or mintYear Mod 4 = 0 Then
boolLeap = True
End If
intMonthCnt = 1
While intMonthCnt < mintMonth
If intMonthCnt = 2 Then
If boolLeap Then
lngResult = lngResult + 29
Else
lngResult = lngResult + 28
End If
ElseIf intMonthCnt < 8 Then
If intMonthCnt Mod 2 Then
lngResult = lngResult + 31
Else
lngResult = lngResult + 30
End If
Else
If intMonthCnt Mod 2 Then
lngResult = lngResult + 30
Else
lngResult = lngResult + 31
End If
End If
intMonthCnt = intMonthCnt + 1
Wend
ReturnNoOfDays = lngResult
Exit Function
Error:
MsgBox "Oooooooops, Contact Mangesh at [email protected]", vbCritical, "Count Days...!!!"
End Function
This code returns the number of days passed since the given year. The date of year is condsidered f Comments
No comments yet — be the first to post one!
Post a Comment