Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f22Fx8x38857 for ; Fri, 2 Mar 2001 10:59:08 -0500 (EST) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f22Dxrx12226 for ; Fri, 2 Mar 2001 08:59:53 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f22DwaK98319 for pgsql-sql@postgresql.org; Fri, 2 Mar 2001 08:58:36 -0500 (EST) (envelope-from news) From: Salvador =?iso-8859-1?Q?Main=E9?= X-Newsgroups: comp.databases.postgresql.sql Subject: Re: dates in functions Date: Fri, 02 Mar 2001 13:57:11 -0100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 44 Message-ID: <3A9FB4C7.A6CF943E@yahoo.com> References: <3A9FB338.A5A174C9@yahoo.com> Reply-To: salva@ronincoders.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: scrappy@hub.org X-Mailer: Mozilla 4.75 [es] (X11; U; Linux 2.2.16-22 i586) X-Accept-Language: en To: pgsql-sql@postgresql.org X-Archive-Number: 200103/25 X-Sequence-Number: 1668 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