Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 3E0279FBA77 for ; Fri, 20 Apr 2007 09:19:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 34380-03 for ; Fri, 20 Apr 2007 09:19:30 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.190]) by postgresql.org (Postfix) with ESMTP id 7A7D69FBA55 for ; Fri, 20 Apr 2007 09:19:35 -0300 (ADT) Received: by mu-out-0910.google.com with SMTP id g7so1047232muf for ; Fri, 20 Apr 2007 05:19:33 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=oiBedT3txqPeBDZfM1GOxcphh38qFKXdBNMald7mff/wZcfgjU4AdSxryf5IKKbFnBYeaiJNheCeslasWRlosOewOGifOTtdELorvLj/11XO2A4WVa0ku+JCtav0DkLTpvR3v3wZV3MHLIIEMHauJEvY4RMyWn0Jl8iwn6HuWj0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=l6+LCfVR8Dpm7KT6miszIDcaG/Fm8antbG57UvuWikyzb65AALGfmB4lMfHO6UWrK38slrfytOsRPjfe9IIkQMwuCt8UiOhvu4ZVhRE2IUYPlVgi7s4JY8PthE5KYrR39j07hky6tGv4tvgfl6bvyFCs3ZfBHq2vECKDLeRHdrc= Received: by 10.82.116.15 with SMTP id o15mr4528921buc.1177071573450; Fri, 20 Apr 2007 05:19:33 -0700 (PDT) Received: by 10.82.187.3 with HTTP; Fri, 20 Apr 2007 05:19:33 -0700 (PDT) Message-ID: <11604f180704200519h5d858f6ey1efbbccd52ccd0c9@mail.gmail.com> Date: Fri, 20 Apr 2007 17:49:33 +0530 From: "Rohit Khare" To: pgsql-sql@postgresql.org Subject: Retrieve month from date MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_153452_19994919.1177071573411" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/177 X-Sequence-Number: 28177 ------=_Part_153452_19994919.1177071573411 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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? ------=_Part_153452_19994919.1177071573411 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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?

------=_Part_153452_19994919.1177071573411--