From: | George Moga <george(at)dsn(dot)ro> |
---|---|
To: | salva(at)ronincoders(dot)com, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: dates in functions |
Date: | 2001-03-05 16:13:25 |
Message-ID: | 3AA3BB25.28A68D8E@dsn.ro |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Salvador Mainé wrote:
> Hello:
>
> I'm trying to define a function that, given a date, returns its month.
> The definition is as follows:
>
> CREATE function anyo_hidro (date) returns int AS '
> BEGIN
> RETURN date_part("month",$1);
> END;
> ' LANGUAGE 'plpgsql';
>
> But when I do:
>
> select anyo_hidro('1-1-1999');
>
> I get the following error:
>
> ERROR: Attribute 'month' not found
Try,
test=# CREATE function anyo_hidro (date) returns int AS '
BEGIN
RETURN date_part(\'month\',$1::datetime);
END;
' LANGUAGE 'plpgsql';
CREATE
test=# select anyo_hidro('1-1-1999');
anyo_hidro
------------
1
(1 row)
I use:
test=# select version();
version
---------------------------------------------------------------
PostgreSQL 7.0.3 on i686-pc-linux-gnu, compiled by gcc 2.95.3
(1 row)
test=#
George Moga,
Data Systems Srl
From | Date | Subject | |
---|---|---|---|
Next Message | clayton cottingham | 2001-03-05 16:40:53 | Re: Two way encryption in PG??? |
Previous Message | Boulat Khakimov | 2001-03-05 14:11:14 | Re: Two way encryption in PG??? |