?
Solved

The best age computation formula

Posted on 2001-07-10
7
Medium Priority
?
583 Views
Last Modified: 2010-07-27
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
0
Comment
Question by:zerobro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

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

J.
0
 

Author Comment

by:zerobro
ID: 6276157
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
0
 

Author Comment

by:zerobro
ID: 6276160
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
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
LVL 4

Expert Comment

by:jsweby
ID: 6276167
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.
0
 

Author Comment

by:zerobro
ID: 6276336
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
0
 
LVL 4

Accepted Solution

by:
jsweby earned 120 total points
ID: 6276346
No, truncate is a mathmatical function that takes a decimal number and returns the number rounded down to the nearest integer, so that 19.52 becomes 19, 19.99 also becomes 19:

Age := Truncate((CurrentDate - {PATIENT.BIRTHDATE}) / 365.25)

J.
0
 

Author Comment

by:zerobro
ID: 6276392
Ok, I got it...thanks for the time...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question