Query: calc. age based on birth date

J

Jan

I have two fields:
1. DOB (date of birth)
2. CreationDate

I would like an output table with 2 columens:
1. DOB
2. Age (Age = Creation Date - DOB)

Age is calculated as number of years. I'm using Access 2003 on XP, any
ideas on how such a calculation query is made?
 
G

Guest

Jan,

Basic calculation is

Age = DatePart("yyyy",CreationDate) - DatePart("yyyy",DOB)

but this needs adjusting if creation date is earlier in the year than date
of birth. So

If DatePart("y",CreationDate) < DatePart("y",DOB) then
Age=Age - 1
End If

Rod
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top