Hi All,
I need to be able to calculate the age of a person in both years and months. The years I have sorted but the code for working out the number of months does not. It appears to work for the first 5 months but after that it goes weird.
VB Code:
'get the age in months Dim date1 As Date Dim date2 As Date Dim mnths As Integer Dim yrs As Integer Dim mnthcalc As Integer 'set date to today date1 = Now date2 = dtDOB.Value mnths = DateDiff(DateInterval.Month, date2, date1) yrs = DateDiff(DateInterval.Year, date2, date1) If yrs = 0 Then txtMonths.Text = mnths Else 'mnthcalc = yrs * 12 'txtMonths.Text = (mnths - mnthcalc) mnthcalc = mnths / 12 txtMonths.Text = mnthcalc End If
any help appreciated.
:)
