Holas tengo la siguiente funcion:
CREATE OR REPLACE FUNCTION uno(fecpago timestamp)
RETURNS record AS
$BODY$declare
resultado record;
mifecha timestamp;
begin
mifecha=(select max(fec_tra) from pre_trn where (tip_trn=2 or
tip_trn=1 or tip_trn=3) and baja='0' and temporal='0' and
fec_tra<=fecpago and num_pre=1);
select (date (mifecha) - date (fecpago)) into resultado;
return resultado;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION uno(fecpago timestamp) OWNER TO postgres;
quiero que me devuelva la diferencia de dias entre las dos fechas que le doy
select (date (mifecha) - date (fecpago)) into resultado;
ya hice la prueba y no me esta votando ningun resultado
gracias de antemano