Query with <= Parameter

  • Thread starter Thread starter joykairos
  • Start date Start date
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
#"?
 
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())
 
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
#"?
 
Back
Top