A query help

  • Thread starter Thread starter Claudi
  • Start date Start date
C

Claudi

Hi,
I have a table with this fields below:

member_number, member_name, date_of_birth payment and current_year

Those members who are 65 years old, don't need to pay the member fee.
My question is, can I use a query to select those members who are 65
years old?
For example,
current year is 2004
date_of_birth is 11-12-1939 then
payment is free

I think I need a function to get the year 1939 in the field
date_of_birth and then use current year value 2004 - 1939 = 65
but, is it possible to do in a query?

My database was created in MS Access 2000

Thanks for any information if someone can help me with this little
problem.


CLaudi
 
Hi Claudi,

A typical expression that computes age
based on a birthdate field called "date_of_birth"
(all one line):

DateDiff("yyyy", [date_of_birth], Date())
- IIF(Format(Date, "mmdd") < Format([date_of_birth], "mmdd"), 1, 0)

So..a query that selects members who are 65 years
old or greater might look like:

SELECT * FROM yourtable
WHERE
DateDiff("yyyy", [date_of_birth], Date())
- IIF(Format(Date, "mmdd") < Format([date_of_birth], "mmdd"), 1, 0) >= 65;

Does that help?

Good luck.

Gary Walter
 
Back
Top