Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 7B3279FBB07 for ; Fri, 20 Apr 2007 14:46:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 55465-08 for ; Fri, 20 Apr 2007 14:46:33 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 4F7DF9FBAF9 for ; Fri, 20 Apr 2007 14:46:33 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Fri, 20 Apr 2007 17:46:28 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 20 Apr 2007 12:46:28 -0500 Subject: Re: Retrieve month from date From: Scott Marlowe To: RPK Cc: pgsql-sql@postgresql.org In-Reply-To: <10106861.post@talk.nabble.com> References: <11604f180704200519h5d858f6ey1efbbccd52ccd0c9@mail.gmail.com> <4628CE32.A3DD.0030.0@indicator.be> <10106861.post@talk.nabble.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1177091187.24411.25.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Fri, 20 Apr 2007 12:46:28 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/196 X-Sequence-Number: 28196 On Fri, 2007-04-20 at 12:30, RPK wrote: > What this query will return: > > Select Extract(Month from 4/20/2007) from dual; > > I suspect "dual" is not for PGSQL but Oracle. But I need to run the above > query. What is the replacement of "dual" in PGSQL. > Well, you're going to have to create a special one row table with contraints and triggers to always keep it at one row and now allow anyone to insert into it and... just kidding. All you need is: select extract(month from '4/20/2007'::date); i.e. no need for the extraneous from dual there.