Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal formula needed to calculate age at a certain date

Status
Not open for further replies.

MulliganWJ

IS-IT--Management
Dec 14, 2011
3
US
Hi ~ I'm hoping someone can help me with a crystal reports formula...
I need to calculate age as of 06/30/2011 and I cannot get the formula correct.
Any help would be appreciated.
Thank you.

Wendy
 
Ok, so the formula on Ken Hamady's page reads as follows:

DateVar Birth:= {ages.Birth}; // Replace this with your field for Date Of Birth
DateVar Ann := {ages.DateAnn}; // Replace this with CurrentDate to get their age as of the time of the report
//or the date field of an event to get their age as of the time of that event.
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1


I have listed the formula as follows but it keeps telling me that I'm missing a date:

DateVar Birth:={vwGenPatInfo.Patient_DOB}; DateVar Ann:= date(2011,06,30);
if (Month(Ann)*100) + Day (Ann)>=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1

Thank you!
 
Just figured it out...
I used the following:

if Month({DOB Field})<7 then {AGE field} else ({AGE Field}-1)

I used 7 because I was attempting to get the age as of June 30th

THanks for the help!!!

Wendy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top