' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Function calcage(d As String) As String
   Dim agey, agem, aged As Integer
   agey = DateDiff("yyyy", d, Now())
   If DatePart("y", d) > DatePart("y", Now()) Then
      agey = agey - 1
   End If
   agem = DateDiff("m", d, Now()) - agey * 12
   If DatePart("y", d) > DatePart("y", Now()) Then
      agem = agem - 1
   End If
   aged = DateDiff("d", DateAdd("m", agem, DateAdd("yyyy", agey, d)), Now())
   calcage = d + " = " + Str(agey) + " " + Str(agem) + " " + Str(aged)
End Function

Function test()
   MsgBox calcage("15-feb-2000")
   MsgBox calcage("16-feb-2000")
   MsgBox calcage("17-feb-2000")
   MsgBox calcage("18-mar-2000")
End Function
