Calculating Age

C

Corinne

I have a table that has a pupil date of birth, in another table I have tests
taken and the date they were taken. The tables have a one to many
relationship. Is it possible to query the chronological age of the pupil on
the date the test was taken?

Thanks once again for any help you can give
 
G

GK

-----Original Message-----
I have a table that has a pupil date of birth, in another table I have tests
taken and the date they were taken. The tables have a one to many
relationship. Is it possible to query the chronological age of the pupil on
the date the test was taken?

Thanks once again for any help you can give

you can use datediff to calculate the age difference
between the date of birth and the date of the test and
then make a query that uses this calculated control. you
may have to format the reusult to get years and months
 
C

Corinne

Could you please give me some help on that. I have never done this before,
so I know as much as I would probably put an expression in the query but
don't know what to put.

Thanks
 
S

Steve Schapel

Corinne,

Make a calculated field in your query, by putting the equivalent of this
in the Field row of a blank column in the design view of the query...
Age:
DateDiff("yyyy",[DOB],[TestDate)+(Format([DOB],"mmdd")>Format([TestDate],"mmdd"))
.... Obviously substitute your actual field names for the DOB and
TestDate I used in my example.
 
S

Steve Schapel

Oops, I see I left out a ] in my expression! Should be...
Age:
DateDiff("yyyy",[DOB],[TestDate])+(Format([DOB],"mmdd")>Format([TestDate],"mmdd"))
 
Top