>*USAGE: REPLACE driver.age WITH GETAGE(driver.dob) > >*PROCEDURE getage >PARAMETERS m.birthday,m.comparedate > >PRIVATE m.yearsold > >* If only one parameter passed, use today's date as the date to >* compare to. > >IF PARAMETERS() = 1 > m.comparedate = DATE() >ENDIF > >IF EMPTY(m.birthday) > RETURN 0 >ENDIF > >* Verify compare DATE is a "DATE" type field. Convert if not. > >IF TYPE("m.comparedate") != "D" > m.comparedate = CTOD(m.comparedate) >ENDIF > >* Verify birthday DATE is a "DATE" type field. Convert it not. > >IF TYPE("m.birthday") != "D" > m.birthday = CTOD(m.birthday) >ENDIF > >* Find out how many years since birthday > >m.yearsold = YEAR(m.comparedate) - YEAR(m.birthday) > >* Find out if the "birtday" DATE has already passed by adding the >* current year to the end of the birthday. > >IF CTOD( ALLTRIM(STR(MONTH(m.birthday)))+'/'+ALLTRIM(STR(DAY(m.birthday))); > +'/'+ALLTRIM(STR(YEAR(m.comparedate))) ) > m.comparedate > m.yearsold = m.yearsold - 1 >ENDIF > >RETURN m.yearsold >>