Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id ED8369FBA9E for ; Fri, 20 Apr 2007 09:29:27 -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 85280-05 for ; Fri, 20 Apr 2007 09:29:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from interscan.indicator.com (mail.indicator.be [193.121.199.3]) by postgresql.org (Postfix) with ESMTP id 534C29FBA97 for ; Fri, 20 Apr 2007 09:29:24 -0300 (ADT) Received: from webaccess.indicator.be ([10.100.1.7]) by interscan.indicator.com with InterScan Message Security Suite; Fri, 20 Apr 2007 14:15:37 +0200 Received: from DOMEXT-MTA by webaccess.indicator.bewith Novell_GroupWise; Fri, 20 Apr 2007 14:29:20 +0200 Message-Id: <4628CE32.A3DD.0030.0@indicator.be> X-Mailer: Novell GroupWise Internet Agent 7.0.1 Date: Fri, 20 Apr 2007 14:29:07 +0200 From: "Bart Degryse" To: Subject: Re: Retrieve month from date References: <11604f180704200519h5d858f6ey1efbbccd52ccd0c9@mail.gmail.com> In-Reply-To: <11604f180704200519h5d858f6ey1efbbccd52ccd0c9@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=__PartB790D403.0__=" X-imss-version: 2.046 X-imss-result: Passed X-imss-approveListMatch: *@indicator.be X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/179 X-Sequence-Number: 28179 --=__PartB790D403.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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? --=__PartB790D403.0__= Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Description: HTML
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" <rpk.general@gmail.com> 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?

--=__PartB790D403.0__=--