Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Age from DateofBirth query

Status
Not open for further replies.

jkscript

Programmer
Jun 20, 2002
9
0
0
GB
I have a table with a dateofbirth field. I have a query which has a calculated field "Age: Int(DateDiff("d", DOB, Date)/365.25)".

This works fine.

I then add criteria to limit the age to a specific range like "BETWEEN 21 AND 50".

Strange thing is, it works fine, but after about 1.5 seconds an error message "Data type mismatch in criteria expression" appears.

I am at a loss.

 
Is the Date of birth stored in table as text or number? Maybe this is the problem.
 
If DOB is stored as text, you probably have a 'bad' date in a record. A separator might be misplaced...

If not, you may have a Null value somewhere in that field.

Out of curiosity: What's the mathematical/logical background for the formula?





[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top