Link to home
Start Free TrialLog in
Avatar of zerobro
zerobro

asked on

The best age computation formula

Hi Experts,

I'm working on a report that computes patient's age.
With Crystal 8, this is not a problem because of the Datediff function but with crystal 7, I need to manipulate date fields to get the patient age.

Can anybody show me the best formula to compute the patient's age in CR7?

TIA,

zero
Avatar of Jason Sweby
Jason Sweby
Flag of United Kingdom of Great Britain and Northern Ireland image

Can't you simply subtract the date of birth from today's date ("Date") and divide the result by 365.25?

J.
Avatar of zerobro
zerobro

ASKER

Hi jsweby,

I have that before but there's a little bit of a problem:

with a patient whose birthdate is 1/3/82, using the formula you propose ((CurrentDate - {PATIENT.BIRTHDATE}) / 365.25) will generate an age of 19.52. This is correct but the thing is, I wanted to round this up. When I do so, it will become 20 which in anyway the wrong age.

When using CR8's DIFFDATE function in the formula:

DateDiff ("YYYY", {PATIENT.BIRTHDATE}, CurrentDate)

The result is 19 which is the right one I need.

Although I have CR8, due to a very valid reason, I need to use CR7 for this report.

That's basically my problem,

zero
Avatar of zerobro

ASKER

Hi jsweby,

I have that before but there's a little bit of a problem:

with a patient whose birthdate is 1/3/82, using the formula you propose ((CurrentDate - {PATIENT.BIRTHDATE}) / 365.25) will generate an age of 19.52. This is correct but the thing is, I wanted to round this up. When I do so, it will become 20 which in anyway the wrong age.

When using CR8's DIFFDATE function in the formula:

DateDiff ("YYYY", {PATIENT.BIRTHDATE}, CurrentDate)

The result is 19 which is the right one I need.

Although I have CR8, due to a very valid reason, I need to use CR7 for this report.

That's basically my problem,

zero
Don't round the age, truncate it so that you always get the whole number, never rounded. The Truncate function will do this for you.

J.
Avatar of zerobro

ASKER

what do you mean truncate?? convert this to a text and parse the needed portion?

please show me how to do this by example.

zero
ASKER CERTIFIED SOLUTION
Avatar of Jason Sweby
Jason Sweby
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zerobro

ASKER

Ok, I got it...thanks for the time...