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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with date of birth field

Status
Not open for further replies.

tonygr

Technical User
Jan 20, 2005
42
GB
Hi All,
Can Anybody help? I would like to do analysis using date of birth, i.e.
Group totals within age groups. for example:
0 - 16 years
17 - 34 years
35 - 60 years
61 years and over.
The data is stored in a sql date field 01/01/1920
I am using CRxi.
I would also like to use the formula in a chart
Any help much appreciated,
Thanks in Advance
Tony
 
Create a formula {@age} using Ken Hamady's formula at and then create a second formula that groups the ages, as in:

if {@age} < 17 then "16 or less" else
if {@age} < 35 then "17 to 34" else
if {@age} < 61 then "35 to 60" else
if {@age} >= 61 then "61+"

You can insert a group on this, and/or use this in a chart as your "on change of" field.

-LB
 
Thanks for that,
Works Great.
Regards
Tony
 
Hi All,
Sorry about this but,
I am a little confused, I tried to use the above suggestion:

WhileReadingRecords;
Datevar Birth:= {TGMEMBERS.DOB};
Datevar Ann := currentdate;
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1

But it keeps asking for a date on the second line when saving. My DOB field is held in a datetime type field, would that make a difference?
any help greatly appreciated
Tony
 
I Sussed it out, Thanks
see below:

WhileReadingRecords;
Datevar Birth:= DateTimeToDate ({TGMEMBERS.DOB});
Datevar Ann:= currentdate;
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1

Thanks again everyone.
Tony
 
You also could have used the following:

Datevar Birth := Date({TGMEMBERS.DOB});

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top