1
1aae
I have take this function from MVP Access Site:
Is there any MVP ENG tell me how can I use this function:
How can I calculate the difference between today date (system date) computer
date and (date of birth)…
I have only txtboxdateof birth user enter the date of birth msgbox display
the AGE
thank you
Function CalcAge(vDate1 As Date, vDate2 As Date, ByRef vYears As Integer,
ByRef vMonths As Integer, ByRef vDays As Integer)
' Comments : calculates the age in Years, Months and Days
' Parameters:
' vDate1 - D.O.B.
' vDate2 - Date to calculate age based on
' vYears - will hold the Years difference
' vMonths - will hold the Months difference
' vDays - will hold the Days difference
vMonths = DateDiff("m", vDate1, vDate2)
vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vDate2)
If vDays < 0 Then
' wierd way that DateDiff works, fix it here
vMonths = vMonths - 1
vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vDate2)
End If
vYears = vMonths \ 12 ' integer division
vMonths = vMonths Mod 12 ' only want leftover less than one year
End Function
Is there any MVP ENG tell me how can I use this function:
How can I calculate the difference between today date (system date) computer
date and (date of birth)…
I have only txtboxdateof birth user enter the date of birth msgbox display
the AGE
thank you
Function CalcAge(vDate1 As Date, vDate2 As Date, ByRef vYears As Integer,
ByRef vMonths As Integer, ByRef vDays As Integer)
' Comments : calculates the age in Years, Months and Days
' Parameters:
' vDate1 - D.O.B.
' vDate2 - Date to calculate age based on
' vYears - will hold the Years difference
' vMonths - will hold the Months difference
' vDays - will hold the Days difference
vMonths = DateDiff("m", vDate1, vDate2)
vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vDate2)
If vDays < 0 Then
' wierd way that DateDiff works, fix it here
vMonths = vMonths - 1
vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vDate2)
End If
vYears = vMonths \ 12 ' integer division
vMonths = vMonths Mod 12 ' only want leftover less than one year
End Function