Solved

The best age computation formula

Posted on 2001-07-10
7
575 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 30 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now