Hello Team,
So I have a Userform that intends to calculate the user age.
Textbox3 = DOB entered by user
Textbox4 = Date entered by user
Commandbutton3 = click to calculate the age
Results of difference go to TextBox6
I have the following code:
Code
Private Sub CommandButton3_Click()
With Me
Me.TextBox6.Value = DateDiff("yyyy", CLng(CDate(.TextBox3)), CLng(CDate(.TextBox4)))
End With
End Sub
The problem with this code is its only calculating the year difference and not exactly what I want.
For instance, DOB of user is 10/1/2002 and the date on textbox4 is 9/1/2020. One look and you can already see this user is below 18.
When I calculate using the above formula, it gives me a result of 18 when it should be 17.
Thank you for any help.