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:
  1. 'get the age in months
  2.             Dim date1 As Date
  3.             Dim date2 As Date
  4.             Dim mnths As Integer
  5.             Dim yrs As Integer
  6.             Dim mnthcalc As Integer
  7.             'set date to today
  8.             date1 = Now
  9.             date2 = dtDOB.Value
  10.  
  11.             mnths = DateDiff(DateInterval.Month, date2, date1)
  12.             yrs = DateDiff(DateInterval.Year, date2, date1)
  13.  
  14.             If yrs = 0 Then
  15.                 txtMonths.Text = mnths
  16.             Else
  17.                 'mnthcalc = yrs * 12
  18.                 'txtMonths.Text = (mnths - mnthcalc)
  19.                 mnthcalc = mnths / 12
  20.                 txtMonths.Text = mnthcalc
  21.             End If

any help appreciated.