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 f22Fxex39014 for ; Fri, 2 Mar 2001 10:59:40 -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 f22Dxqx12224 for ; Fri, 2 Mar 2001 08:59:52 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f22Dq7E98235 for pgsql-sql@postgresql.org; Fri, 2 Mar 2001 08:52:07 -0500 (EST) (envelope-from news) From: Salvador =?iso-8859-1?Q?Main=E9?= X-Newsgroups: comp.databases.postgresql.sql Subject: dates in functions Date: Fri, 02 Mar 2001 13:50:32 -0100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 28 Message-ID: <3A9FB338.A5A174C9@yahoo.com> Reply-To: salva@ronincoders.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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/26 X-Sequence-Number: 1669 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