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

person's age,, formaula question

Status
Not open for further replies.

jmd0252

Programmer
May 15, 2003
667
OK I found the formula to calculate a person's age,, using a field that is defined as a date. But I have a field that is defined as a string,, how can I conver it to a date?? my sting has 20080101,, for it's value,, for example this is the formula I am trying to figure out,,

DateValue ({PM_EMPMASTER.BIRTH_DATE});
DateVar Birth:= {PM_EMPMASTER.BIRTH_DATE};
DateVar Ann := CurrentDate;
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1

but line 2 kicks with the message it has to be a date,, so what have I done wrong????

bear with me boys and girls,, I am just learning crystal
thanks,, for any and all help
 
stringvar x := {PM_EMPMASTER.BIRTH_DATE};
datevar birth := date(val(left(x,4)),val(mid(x,5,2)),val(right(x,2)));
DateVar Ann := CurrentDate;
if (Month(Ann) * 100) + Day (Ann) >=(Month(Birth) *100) + Day (Birth)
then Year (Ann) - Year(Birth)
else Year (Ann) - Year(Birth) -1

Looks like Ken Hamady's formula--to acknowledge the source.

-LB
 
you are correct it is Ken's formula,, I did a search before I ask the question,, I will give this a try,, thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top