Specific Age Query for a Date Range

B

B. Levien

Table = Personal
Field = Birthdate

I need to create a query to show who is of a certain age for January 1, 2008
to December 31, 2008.

For example, I need to know who will be 50, 60, 65, 70 and 75.

I would like to create the query so that when I click the query to open it,
I have to input the age.

I've done other queries to show who is of a specific age as of today:
AgeYears:
DateDiff("yyyy",[Birthdate],Date())-IFF(Format([Birthdate],"mmdd")>Format(Date(),"mmdd",1,0),
with criteria of [Age in Years] ... but I cannot figure out how to pull a
report saying who will be 50 this year, or 60 or 65, for the entire year
beginning January 1.

Can anyone please point me in the right direction?
 
D

Douglas J. Steele

I'm not sure your question makes sense. Unless the person's birthday is
January 1st, they're not going to have the same age for the entire year!

If what you're trying to do is get a list of everyone who'll be, say, 50
during the year, you can simply look at the year of birth. If it's 50 less
than the current year, you've found them.
 
K

Klatuu

If they will turn a specific age this year, you don't need to calculate the
month. The following expression will return the number of years between the
birthday year and the current year. The person will turn that age sometime
during the year. The filter for the year values you want:

Calculate
AgeYears: Year(Date) - Year([Birthdate])

Filter for years
Where Year(Date) - Year([Birthdate]) IN(50, 60, 65, 70, 75)
 
B

B. Levien

Klatuu, that is EXACTLY what I was looking for!!!! Thank you very much!!!!

Klatuu said:
If they will turn a specific age this year, you don't need to calculate the
month. The following expression will return the number of years between the
birthday year and the current year. The person will turn that age sometime
during the year. The filter for the year values you want:

Calculate
AgeYears: Year(Date) - Year([Birthdate])

Filter for years
Where Year(Date) - Year([Birthdate]) IN(50, 60, 65, 70, 75)
--
Dave Hargis, Microsoft Access MVP


B. Levien said:
Table = Personal
Field = Birthdate

I need to create a query to show who is of a certain age for January 1, 2008
to December 31, 2008.

For example, I need to know who will be 50, 60, 65, 70 and 75.

I would like to create the query so that when I click the query to open it,
I have to input the age.

I've done other queries to show who is of a specific age as of today:
AgeYears:
DateDiff("yyyy",[Birthdate],Date())-IFF(Format([Birthdate],"mmdd")>Format(Date(),"mmdd",1,0),
with criteria of [Age in Years] ... but I cannot figure out how to pull a
report saying who will be 50 this year, or 60 or 65, for the entire year
beginning January 1.

Can anyone please point me in the right direction?
 

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