Sub Dates Times Class

UniqueYearsVerify

Signature (Visual Basic / VBA)

Private Sub UniqueYearsVerify()
    ' Print the years which have fewer than 365 or more than 366 days
    ' (counting from Jan. 1 of the year to Jan. 1 of the next year).

    Dim lngYear As Long
    For lngYear = Year(MinDate) To Year(MaxDate) - 1
        Dim lngDays As Long
        lngDays = CLng(DateSerial(lngYear + 1, 1, 1)) - CLng(DateSerial(lngYear, 1, 1))
        If lngDays < 365 Or lngDays > 366 Then
            Debug.Print "Year " & lngYear & ": " & lngDays & " Days"
        End If
    Next lngYear
End Sub