>The system I am writing needs to validate people applying for an account as being 18 years old or older. Anyone under 18 should not be allowed an account. It sounds simple, but one of my versions that included detection of leap years got very complicated, hence my question here.
>
>Simon
Simon, try this & see if it works for You (the function is not very well tested):
? CalcAge(DATE(1965, 4, 26), DATE(2004,4,27))
FUNCTION CalcAge(b_day, to_date)
LOCAL fmnts, smnts
fmnts = YEAR(b_day) *12+MONTH(b_day)
IF MONTH(to_date) == MONTH(b_day) .AND.;
DAY(to_date) < DAY(b_day)
smnts = YEAR(to_date)*12+(MONTH(to_date)-1)
ELSE
smnts = YEAR(to_date)*12+MONTH(to_date)
ENDIF
RETURN INT((smnts-fmnts)/12)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.