How do you convert Bday into Date in VBA
Hi,
one way:
Sub test()
MsgBox DateDifY(DateSerial(1980, 7, 24), Date)
End Sub
Function DateDifY(Date1 As Date, Date2 As Date) As Long
Dim y As Integer, m As Integer, d As Integer
If Date1 Date2 Then
DateDifY = -1
Else
y = Year(Date2) - Year(Date1)
m = Month(Date2) - Month(Date1)
d = Day(Date2) - Day(Date1)
If d < 0 Then m = m - 1
If m < 0 Then y = y - 1
DateDifY = y
End If
End Function
--
HTH
okaizawa
postlp60 wrote:
I am trying to find a way to convert a persons birthday into their age,
in years with todays date. I know how to make this convresion using
Excel cells but I cannot figure it out using VBA. Please help.
|