Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

locate records based on an age range for a date range

Status
Not open for further replies.

crogers111

Technical User
Jan 23, 2004
158
US
CR XI
SQL

I have Date of Birth and I need to pull records for individuals that were between the ages of 55 & 64 at anytime between the dates of 7/1/2009 & 12/31/2010

I've used KH's age formula many times but am not sure how to apply it for this problem.
 
Appears I just needed to step away to figure this out.

@AgeBegRange
WhileReadingRecords;
DateVar Birth:= cdate({EE.BirthDate});
DateVar Ann := cdate(2009,7,1);
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1


@AgeEndRange
WhileReadingRecords;
DateVar Birth:= cdate({EE.BirthDate});
DateVar Ann := cdate(2010,12,31);
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1


Record Selection Criteria

({@AgeBegRange} >= 55 and {@Age-BegRange} <= 64)
or
({@AgeEndRange} >= 55 and {@Age-EndRange} <= 64))



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top