"Eduardo Cadena" <ecadenag(at)hotmail(dot)com> writes:
> CREATE FUNCTION month(timestamp) RETURNS date AS '
> DECLARE
> fecha ALIAS FOR $1 ;
> mes int4;
> BEGIN
> SELECT INTO mes EXTRACT (MONTH FROM TIMESTAMP (fecha) );
> RETURN mes;
> END
> ' LANGUAGE PLPGSQL;
Try just
SELECT INTO mes EXTRACT (MONTH FROM fecha);
$1 already is a timestamp, and your attempt to do an unnecessary
coercion via function syntax is running into the problem that
TIMESTAMP(...) is a reserved syntax per SQL.
regards, tom lane