How do I sort a DateDiff result in an Access query?

D

Daniel W

I want to calculate age, and then sort by that age and/or select only a
certain age range for output in my query. To calculate age in a query, I am
using DateDiff("yyyy",[DateOfBirth],Now()). The resultant age is correct,
however, I am unable to enter criteria or sort without receiving a data
mismatch error. I've tried numeric, text, and date formats in the event I
set the type wrong somewhere. I've also tried using a query that calculated
age as input into another query in which I'd enter the criteria, but I still
receive the data mismatch error.
 
D

Duane Hookom

Are you sure your calculations are correct? If a person was born,
12/31/2004, your calc would have them at a year old. If the person was born,
1/1/2005, his/her age would always be the same as someone born 12/31/2005.

There are better calcs at http://www.mvps.org/access/datetime/date0001.htm.

What is the SQL view of a query that didn't work?
 

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