Public Class MainClass
Public Function YearsBetweenDates(ByVal StartDate As DateTime, ByVal EndDate As DateTime) As Integer
If Month(EndDate) < Month(StartDate) Or (Month(EndDate) = Month(StartDate) And(EndDate.Day) < (StartDate.Day)) Then
Return Year(EndDate) - Year(StartDate) - 1
Else
Return Year(EndDate) - Year(StartDate)
End If
End Function
End Class
|