Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 5F85D9FB4C6 for ; Wed, 18 Apr 2007 14:36:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 92204-03 for ; Wed, 18 Apr 2007 14:36:14 -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 A3B0C9FA195 for ; Wed, 18 Apr 2007 14:36:20 -0300 (ADT) Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1HeE4l-0002s7-1V for pgsql-sql@postgresql.org; Wed, 18 Apr 2007 10:36:15 -0700 Message-ID: <10063035.post@talk.nabble.com> Date: Wed, 18 Apr 2007 10:36:14 -0700 (PDT) From: RPK To: pgsql-sql@postgresql.org Subject: Retrieve month from date in SQl query MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: rpk.general@gmail.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/206 X-Sequence-Number: 28206 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-in-SQl-query-tf3602302.html#a10063035 Sent from the PostgreSQL - sql mailing list archive at Nabble.com.