Retrieve month from date

From: "Rohit Khare" <rpk(dot)general(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Retrieve month from date
Date: 2007-04-20 12:19:33
Message-ID: 11604f180704200519h5d858f6ey1efbbccd52ccd0c9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message A. Kretschmer 2007-04-20 12:20:16 Re: many 'OR' in WHERE-condition
Previous Message Richard Huxton 2007-04-20 11:59:01 Re: many 'OR' in WHERE-condition