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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ken Hamady's Age formula 1

Status
Not open for further replies.

Tech2377

Programmer
Nov 13, 2007
81
Using Crystal 10. I was referenced to use Ken Hamady's Age formula.


When I use this, I get an error on {SB1001_main.PatientBirthdate}. It keeps telling me "A date is required here". This is a DateTime field so I guess Im stumped.

Code:
WhileReadingRecords;
DateVar Birth:= {SB1001_main.PatientBirthdate};   // Replace this with your field for Date Of Birth
DateVar Ann := {SB1001_main.ApptStart};  // 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
 
Change to

WhileReadingRecords;
DateVar Birth:= date({SB1001_main.PatientBirthdate}); // Replace this with your field for Date Of Birth
DateVar Ann := date({SB1001_main.ApptStart}); // 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

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top