I have a UDF (It's for Mr. Hans) that calculates the age
Code: Select all
Function CalculateAge(birth, start, txt As String)
Dim y As Long, m As Long, d As Long
If Not IsDate(birth) Or Not IsDate(start) Then GoTo Skipper
m = DateDiff("m", birth, start)
d = DateDiff("d", DateAdd("m", m, birth), start)
If d < 0 Then
m = m - 1
d = DateDiff("d", DateAdd("m", m, birth), start)
End If
y = m \ 12
m = m Mod 12
Select Case txt
Case "d"
CalculateAge = d
Case "m"
CalculateAge = m
Case "y"
CalculateAge = y
End Select
Exit Function
Skipper:
CalculateAge = ""
End Function
For example: the bof 31/12/2009 ... and the start date is 1/10/2021 (First of October)
The result of the udf is 11-09-01
while when using formulas like that
Code: Select all
=IF(A2="","",IF(A2>1,DATEDIF(A2,Start_Date,"md"),""))
11-09-00
Which is correct in that case ??