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

Date to Age

Status
Not open for further replies.

herschelrj

Programmer
Jan 12, 2005
24
0
0
US
I need a formula that will convert the date of birth to their current age. Any help would be appreciated...

Crystal Reports 10
 
I tried this formula and when I check it, I get an error that says a date id required here where I replared the fild for the date. Can you help???

WhileReadingRecords;
DateVar Birth:= {NC_05.DOB}; // Replace this with your field for Date Of Birth
DateVar Ann := CurrentDate; // 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
 
What is the datatype for your DOB field? You can run the mouse over it to see the tooltip text which will say whether it's a date, datetime, or string. If it is a string, please show some samples of the field and identify which characters represent days versus months.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top