How do you want to treat leap year? If date range includes a Feb 29, do you want to subtract a day?
days between 20/5/20 AND 19/5/24 = 1461
One of those days is Feb 29, 2024.
Following can determine if a year is a leap year.
Month(DateSerial(yr, 2, 29)) = 2
How do you want to determine if period is more than a year - more than 365 days? How should leap year be considered?
Something to get you started:
Code:
Function GetDate(dteD1 As Date, intYrs As Integer)
Dim dteD2 As Date, intDays As Integer
dteD2 = DateAdd("yyyy", intYrs, dteD1)
intDays = DateDiff("d", dteD1, dteD2)
GetDate = DateAdd("d", -1 * Round(intDays / IIf(intDays > 365, 3, 2), 0), dteD2)
End Function