Print Page | Close Window

Age Calculation Formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22848
Printed Date: 29 Apr 2024 at 6:05am


Topic: Age Calculation Formula
Posted By: NCGOV
Subject: Age Calculation Formula
Date Posted: 19 Dec 2019 at 7:51am
I need an age calculation formula that will look for blank DOB fields and display nothing for the age field. The formula I have excludes all of the name if the DOB is blank.

Age Formula - INT((CurrentDate-{name.dob})/365.25)


Entire Name Formula -
local stringvar ls := trim({name.lastname}) & " " & trim({name.suffix});
local stringvar fm := trim({name.firstname}) & " " & trim({name.middlename});
local stringvar fn;
If length(trim((ls))) > 0 and length(trim((fm))) > 0 then
    fn := trim(ls) & ", " & trim(fm)
else
    fn := trim(ls) & trim(fm);

If length({name.race}) < 1  then
    local stringvar rc := "-"
else rc := {name.race} & "/";

If length({name.sex}) < 1  then
    local stringvar sx := " - "
else sx := {name.sex};

fn & " - "& trim (rc) & trim (sx) & " "& " " & trim ({name.age})



Replies:
Posted By: kevlray
Date Posted: 19 Dec 2019 at 10:26am
Many years ago Ken Hamady creates a formula that I consider a very good on.  Check out his web site. http://www.kenhamady.com/ - http://www.kenhamady.com



Print Page | Close Window