Search Postgresql Archives

problems with function pg_catalog.btrim(date)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everybody,

I hope some one can help me, I have created the following function but I always get the error that there is not function pg_catalog.btrim(date), in the version postgresql 8.1 it worked but now it does not so I don't know if it is related with a configuration problem of the postgresql or somethin in the function code :

thanks

karina

CREATE FUNCTION edad(date) RETURNS integer
   AS $_$
DECLARE
fechnac ALIAS FOR $1;
dia_nac integer;
mes_nac integer;
anho_nac integer;
fecha_nac  date;
fecha_temp text;
hoy date;
dia  integer;
mes  integer;
anho integer;
temp integer;
edad integer;



BEGIN



hoy := current_date;
hoy := date(trim(hoy));

fecha_nac:= date(trim(fechnac));
fecha_temp:=CAST(fecha_nac  AS  text );


dia_nac :=CAST(substring(fecha_temp from 1 for 2)  AS integer );
mes_nac := CAST (substring(fecha_temp from 4 for 2) AS integer);
anho_nac :=CAST(substring(fecha_temp from 7 for 4) AS integer );


dia :=CAST(substring(hoy from 1 for 2)  AS integer );
mes := CAST (substring(hoy from 4 for 2) AS integer);
anho := CAST(substring(hoy from 7 for 4) AS integer );



edad:= (anho-anho_nac)-1;

IF mes+1-mes_nac < 0  THEN
RETURN edad;
END IF;


IF mes+1-mes_nac < 0  THEN
RETURN edad;
END IF;



IF mes+1-mes_nac > 0  THEN
RETURN edad+1;
END IF;


IF dia-dia_nac >= 0  THEN
RETURN edad+1;
ELSE
RETURN edad;
END IF;
END;

$_$
   LANGUAGE plpgsql;


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux