|
|
Расчёт кол-ва дней до следующего дня рождения
Public Function DaysToBirthDay(vBirthDay As Variant, Optional iMaxDaysLimit% = 365) As Integer
Dim iThisYear As Integer, iMonth As Integer, iDay As Integer
Dim dDateOfNextBD As Date
On Error GoTo DaysToBirthDay_Err
iThisYear = Year(Date)
iMonth = Month(vBirthDay)
iDay = Day(vBirthDay)
dDateOfNextBD = DateSerial(iThisYear, iMonth, iDay)
If dDateOfNextBD < Date Then
dDateOfNextBD = DateSerial(iThisYear + 1, iMonth, iDay)
End If
iDay = DateDiff("d", Date, dDateOfNextBD)
If iDay <= iMaxDaysLimit Then DaysToBirthDay = iDay
Exit Function
DaysToBirthDay_Err:
Err.Clear: DaysToBirthDay = -1
End Function
|
|