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!

Adding ages that have a "Y" (e.g., 47Y) in the field

Status
Not open for further replies.

JonathanNYC

IS-IT--Management
Mar 29, 2003
111
US
I am using Crystal 8.0.
Field name "patient age" is representing age as: 47Y and 23Y and 9Y and so on. There are also some ages with "M" (to indicate months old - but I am not worried about that for now).

I need to provide average (patient) age for a Researcher.
Is there a formula that "strips off" the Y or allows me to add up the numbers so that I may arrive at a grand total and an average age ?
 
Something like this should work:

if instr({table.age},"Y") > 0 then
val(replace({table.age},"Y",""))
else if instr({table.age},"M") > 0 then
val(replace({table.age},"M",""))/12
else
0

-k
 
Thanks synapsevampire. I did find that we capture birthdate. So, I did a formula subtracting birthdate from surgery date and divided by 365. I think your solution wold have worked too. Appreciate the help.

 
thanks k, i don't need it to be precise, if the age is within 90 days of being correct it is acceptable for my purposes. I am looking at thousands of patients that have undergone certain procedures. If their age is 26.23 or 26.43 that is acceptable for my purposes. thanks for your input.
 
OK k, now you are inspiring me. Thanks for the link. It works perfectly. How can I modify it to include more that just the age integer. For example, it shows 28 and what if I want 28.46. Have a happy and safe New Year.
 
Try:

WhileReadingRecords;
DateVar Birth:= {ages.Birth};
if (Month({table.birth}) * 100) + Day (currentdate) >=(Month({table.birth}) *100) + Day ({table.birth})
then datediff("yyyy",{table.birth},currentdate)
else datediff("yyyy",{table.birth},currentdate)-1

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top