[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

The best age computation formula

Posted on 2001-07-10
7
Medium Priority
?
585 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
What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 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