Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id B898F9FBA5F for ; Fri, 20 Apr 2007 14:30:28 -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 53254-01 for ; Fri, 20 Apr 2007 14:30:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from talk.nabble.com (www.nabble.com [72.21.53.35]) by postgresql.org (Postfix) with ESMTP id 52FBA9FBA16 for ; Fri, 20 Apr 2007 14:30:17 -0300 (ADT) Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1Heww4-0008P2-F9 for pgsql-sql@postgresql.org; Fri, 20 Apr 2007 10:30:16 -0700 Message-ID: <10106861.post@talk.nabble.com> Date: Fri, 20 Apr 2007 10:30:16 -0700 (PDT) From: RPK To: pgsql-sql@postgresql.org Subject: Re: Retrieve month from date In-Reply-To: <4628CE32.A3DD.0030.0@indicator.be> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: rpk.general@gmail.com References: <11604f180704200519h5d858f6ey1efbbccd52ccd0c9@mail.gmail.com> <4628CE32.A3DD.0030.0@indicator.be> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/194 X-Sequence-Number: 28194 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. Bart Degryse wrote: > > Please always include the error message you get when something isn't > working. > > If you defined your table with quoted identifiers (create table > "StudentFeesPayment" as ...) then try > Select max("ReceiptNo") from "StudentFeesPayment" where Extract(Month > from "ReceiptMonthYear")=4; > else try > Select max(ReceiptNo) from StudentFeesPayment where Extract(Month > from ReceiptMonthYear)=4; > > > >>>> "Rohit Khare" 2007-04-20 14:19 >>> > I am using PGSQL 8.2.3 on Windows XP. > > I have a table called "StudentFeesPayment" with columns "ReceiptNo" and > "ReceiptMonthYear". > The column, "ReceiptMonthYear" stores date in the format "yyyy-mm-dd". > I have to find the max(ReceiptNo) where Month of (ReceiptMonthYear)=4. > Or whatever month I give. > > I tried: > > Select max(ReceiptNo) from StudentFeesPayment where > Extract(Month('ReceiptMonthYear'))=4; > > But it is not working. How to do it? > > > -- View this message in context: http://www.nabble.com/Retrieve-month-from-date-tf3617513.html#a10106861 Sent from the PostgreSQL - sql mailing list archive at Nabble.com.