Query to find list of persons whose age is below/above input age

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a Database, which contains details of persons like Name, Age, Sex,
Address.
i want to make a query, in which, the query should ask for the min/max age
and then should display the details of persons whose age are above/below the
age given as input.
ex: query should ask "Details of persons whose age is below.." and when
input is given as 40, then the query should display the details of persons
whose age is below 40.
how can i do it. please help me
thank u
 
Try this

' Between two ages input
Select * from TableName Where AgeFieldName Between [Enter Min Date:] And
[Enter Max Date:]

'Below an age
Select * from TableName Where AgeFieldName < [Details of persons whose age
is below:]
 
Why are you storing "age"? This changes. You should store their
birthdates, then calculate age.

Storing age only lets you know how old they were the day the data was
entered. Is that acceptable? Will you not be using this database next
year?

If you DON'T change your structure, then just put criteria under your "age"
field in your query like...

Between [Enter Start Age] and [Enter End Age]


But again, your data structure is most likely flawed unless you only want to
keep age at a particular point in time. I'd use birthdate.
 
On Mon, 12 Sep 2005 09:48:02 -0700, "leo pradeep" <leo
i have a Database, which contains details of persons like Name, Age, Sex,
Address.

Age is really not suitable for a stored field. If you query the table
today, my age is 59; if you query it this time next year I'll be 60.

Storing the age is only appropriate if the table is for VERY temporary
use! You may instead want to store birthdates, and calculate the age
dynamically with an expression:

Age: DateDiff("yyyy", [DOB], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)

i want to make a query, in which, the query should ask for the min/max age
and then should display the details of persons whose age are above/below the
age given as input.
ex: query should ask "Details of persons whose age is below.." and when
input is given as 40, then the query should display the details of persons
whose age is below 40.
how can i do it. please help me
thank u

Create a Query and on the criteria line under Age (your field or the
calculated one) put

<= [Details of persons whose age is below:]

Use >= for the "older" query.

John W. Vinson[MVP]
 

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

Back
Top