Re: [SQL] Retrieve month from date in SQl query

2007-04-23 Thread Michael Fuhr
On Wed, Apr 18, 2007 at 10:36:14AM -0700, RPK wrote: > I have a table called "StudentFeesPayment" with columns "ReceiptNo" and > "ReceiptMonthYear". > The column, "ReceiptMonthYear" stores date in the format "-mm-dd". I > have to find the max(ReceiptNo) where Month of (ReceiptMonthYear)=4. Or >

[SQL] Retrieve month from date in SQl query

2007-04-22 Thread RPK
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 "-mm-dd". I have to find the max(ReceiptNo) where Month of (ReceiptMonthYear)=4. Or whatever month I give.

Re: [SQL] Retrieve month from date

2007-04-20 Thread Scott Marlowe
On Fri, 2007-04-20 at 12:30, RPK wrote: > 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. > Well, you're going to have to create a

Re: [SQL] Retrieve month from date

2007-04-20 Thread A. Kretschmer
am Fri, dem 20.04.2007, um 10:30:16 -0700 mailte RPK folgendes: > > 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. Simply "selec

Re: [SQL] Retrieve month from date

2007-04-20 Thread RPK
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

Re: [SQL] Retrieve month from date

2007-04-20 Thread Rodrigo De León
On 4/20/07, RPK <[EMAIL PROTECTED]> wrote: Thanks both of you, I ran EXPLAIN command on above suggested query and got following result: "Aggregate (cost=2.77..2.79 rows=1 width=10)" " -> Seq Scan on studentfeespayment (cost=0.00..2.77 rows=1 width=10)" "Filter: (date_part('month'::

Re: [SQL] Retrieve month from date

2007-04-20 Thread RPK
Thanks both of you, I ran EXPLAIN command on above suggested query and got following result: "Aggregate (cost=2.77..2.79 rows=1 width=10)" " -> Seq Scan on studentfeespayment (cost=0.00..2.77 rows=1 width=10)" "Filter: (date_part('month'::text, (recieptmonthyear)::timestamp without t

[SQL] Retrieve month from date

2007-04-20 Thread Rohit Khare
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 "-mm-dd". I have to find the max(ReceiptNo) where Month of (ReceiptMonthYear)=4. Or whatever month I give.

Re: [SQL] Retrieve month from date

2007-04-20 Thread Bart Degryse
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

Re: [SQL] Retrieve month from date

2007-04-20 Thread A. Kretschmer
am Fri, dem 20.04.2007, um 17:49:33 +0530 mailte Rohit Khare folgendes: > 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 "-mm-dd". I have > to fi