Re: dates in functions

From: Salvador Mainé <salvamaine(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: dates in functions
Date: 2001-03-02 14:57:11
Message-ID: 3A9FB4C7.A6CF943E@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

The correct function is:

CREATE function anyo_hidro (date) returns int AS '
BEGIN
RETURN date_part(''month'',$1);
END;
' LANGUAGE 'plpgsql';

By the way: Do you know what 'RTFM' means?

Salvador Mainé escribió:
>
> 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
>
> Why doesn't date_part work with pl/sql functions?
>
> Thanks
>
> --
> Salvador Maine
> http://www.ronincoders.com

--
Salva

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Hannu Krosing 2001-03-02 15:03:05 Re: [HACKERS] why the DB file size does not reduce when 'delete' the data in DB?
Previous Message Salvador Mainé 2001-03-02 14:50:32 dates in functions