Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / September 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
leo pradeep - 12 Sep 2005 17:48 GMT
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
Ofer - 12 Sep 2005 18:08 GMT
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:]

Signature

I hope that helped
Good luck

> i have a Database, which contains details of persons like Name, Age, Sex,
> Address.
[quoted text clipped - 6 lines]
> how can i do it. please help me
> thank u
Rick B - 12 Sep 2005 18:09 GMT
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.
Signature

Rick B

> i have a Database, which contains details of persons like Name, Age, Sex,
> Address.
[quoted text clipped - 6 lines]
> how can i do it. please help me
> thank u
John Vinson - 12 Sep 2005 18:58 GMT
>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
[quoted text clipped - 4 lines]
>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]    
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.