Received: from maia.hub.org (maia-4.hub.org [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 31E28633A10 for ; Tue, 18 May 2010 16:27:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 86589-09 for ; Tue, 18 May 2010 19:27:23 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mh5.mail.rice.edu (mh5.mail.rice.edu [128.42.199.32]) by mail.postgresql.org (Postfix) with ESMTP id CB937633723 for ; Tue, 18 May 2010 16:27:23 -0300 (ADT) Received: from mh5.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh5.mail.rice.edu (Postfix) with ESMTP id E5A6C15C05A; Tue, 18 May 2010 14:27:22 -0500 (CDT) X-Virus-Scanned: by amavis-2.6.0 at mh5.mail.rice.edu Received: from mh5.mail.rice.edu ([127.0.0.1]) by mh5.mail.rice.edu (mh5.mail.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MBaY6kBAiqZm; Tue, 18 May 2010 14:27:22 -0500 (CDT) Received: from aart.is.rice.edu (aart.is.rice.edu [168.7.56.48]) by mh5.mail.rice.edu (Postfix) with ESMTP id BC82315C047; Tue, 18 May 2010 14:27:22 -0500 (CDT) Received: by aart.is.rice.edu (Postfix, from userid 18612) id 6F6882D5A6; Tue, 18 May 2010 14:27:22 -0500 (CDT) Date: Tue, 18 May 2010 14:27:21 -0500 From: Kenneth Marshall To: Richard Broersma Cc: pgsql-sql@postgresql.org Subject: Re: How to get CURRENT_DATE in a pl/pgSQL function Message-ID: <20100518192721.GS3892@aart.is.rice.edu> References: <20100518190832.GQ3892@aart.is.rice.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.16 (2007-06-09) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.21 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/79 X-Sequence-Number: 34127 To follow-up, It works using 'now' and I assume that since curtime is of type DATE that the assignment casts the return automatically to type DATE. Thank you for the ideas. Regards, Ken On Tue, May 18, 2010 at 12:12:46PM -0700, Richard Broersma wrote: > On Tue, May 18, 2010 at 12:08 PM, Kenneth Marshall wrote: > > > http://www.postgresql.org/docs/8.4/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT > > > > you can use CURRENT_DATE. When I try to use it in > > the following pl/pgSQL function it gives the error: > > > BEGIN > > ? ?curtime := 'CURRENT_DATE'; > > ? ?LOOP > > > I'm not "up" on my pl/pgSQL, but isn't CURRENT_DATE a literal value so > it shouldn't to be enclosed in single quotes? > > Another idea would be to: CAST( now() AS DATE ) > > > > -- > Regards, > Richard Broersma Jr. > > Visit the Los Angeles PostgreSQL Users Group (LAPUG) > http://pugs.postgresql.org/lapug >