Age Calculations

eyalco

Registered User.
Local time
Today, 02:53
Joined
Jul 24, 2007
Messages
50
I'm having a problem with this age formula in the query :

AGE: DateDiff("yyyy",[birth_date],Date()) & " " & " years" & " " & "and" & " " & DateDiff("m",[birth_date],Date()) Mod 12 & " " & "months"

Need your help guys in 2 probs :
1. age calculated is not right.
2. need to compute what w'd be age on the sep 1st 2008 - how do I do it?

Appreciate your help.
Thanks.
 
You need to rename your date field to something else since Date is the name of an Access function.

Try this:
Code:
Function fAge2(DOB As Date, dteEnd As Date) As Integer
'Inputs:  1) ? fAge2(#4/13/53#, #10/23/06#)
'         2) ? fAge2(#11/1/53#, #10/23/06#)
'Outputs: 1) 53
'         2) 52

   fAge2 = DateDiff("yyyy", DOB, dteEnd) + (DateSerial(Year(dteEnd), Month(DOB), Day(DOB)) > dteEnd)

End Function
HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom