FUNCTION AgeInYrs LPARAMETERS pbDate, pcalcDate LOCAL lbmonth, lncmonth, lnyears, ldcurrdate IF PCOUNT() > 1 ldcurrdate = pcalcdate ELSE ldcurrdate = DATE() ENDIF lnyears = YEAR(pbdate) - YEAR(ldcurrdate) IF lnyears > 0 lnbmonth = MONTH(pbdate) lncmonth = MONTH(ldcurrdate) IF lncmonth <= lnbmonth IF lncmonth < lnbmonth lnyears = lnyears - 1 ELSE IF DAY(ldcurrdate) < DAY(pbdate) lnyears = lnyears - 1 ENDIF ENDIF ENDIF ENDIF RETURN lnyears