Query with <= Parameter

J

joykairos

I need a report that will pull a certain age population, and would need a
query to pull the employees that are 24 years old and younger and 65 years
old and older. I could just enter the parameters directly and 'hard code' it
but is there other way to do a query that will ask the "Between Age # and Age
#"?
 
D

Douglas J. Steele

Assuming you've got a field named Age in your table (which you shouldn't...)

WHERE [Age] <= [Younger Age?]
OR [Age] >= [Older Age?]

If you've only got DateOfBirth (like you should!)

WHERE [DOB] >= DateAdd("yyyy", -[Younger Age?], Date())
OR [DOB] <= DateAdd("yyyy", -[Older Age?], Date())
 
J

joykairos

Thanks! That works and helps a lot with my reporting!

Douglas J. Steele said:
Assuming you've got a field named Age in your table (which you shouldn't...)

WHERE [Age] <= [Younger Age?]
OR [Age] >= [Older Age?]

If you've only got DateOfBirth (like you should!)

WHERE [DOB] >= DateAdd("yyyy", -[Younger Age?], Date())
OR [DOB] <= DateAdd("yyyy", -[Older Age?], Date())

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


joykairos said:
I need a report that will pull a certain age population, and would need a
query to pull the employees that are 24 years old and younger and 65 years
old and older. I could just enter the parameters directly and 'hard code'
it
but is there other way to do a query that will ask the "Between Age # and
Age
#"?
 

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