How to create function which returns persons age in years?
Function parameters:
ldDob - Day Of birth
ldDate - Day where age is returned
I tried
CREATE OR REPLACE FUNCTION public.age(date, date, out integer) IMMUTABLE AS
$_$
SELECT floor(INT($2::text::integer-$1::text::integer)/10000);
$_$ language sql
but got
ERROR: syntax error at or near "("
In VFP I can use
RETURN floor(INT((VAL(DTOS(ldDate))-VAL(DTOS(ldDob))))/10000)
or
RETURN (year(ldDate) - year(ldDOB) - ;
iif( str(month(ldDate),2) + str(day(tdDate),2) < ;
str(month(tdDOB),2) + str(day(tdDOB),2), 1, 0) )
Andrus.