Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 75ABC2E0055 for ; Thu, 24 Apr 2008 10:16:21 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 41817-08 for ; Thu, 24 Apr 2008 10:15:57 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from tomts43-srv.bellnexxia.net (tomts43.bellnexxia.net [209.226.175.110]) by developer.postgresql.org (Postfix) with ESMTP id 856AD2E0048 for ; Thu, 24 Apr 2008 10:16:05 -0300 (ADT) Received: from toip7.srvr.bell.ca ([209.226.175.124]) by tomts43-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20080424131604.DCQY1582.tomts43-srv.bellnexxia.net@toip7.srvr.bell.ca> for ; Thu, 24 Apr 2008 09:16:04 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArEEAColEEhBX6ix/2dsb2JhbACBUqtv Received: from bas3-london14-1096788145.dsl.bell.ca (HELO t60p.bax.ca) ([65.95.168.177]) by toip7.srvr.bell.ca with ESMTP; 24 Apr 2008 09:18:45 -0400 Message-ID: <48108813.6070401@sympatico.ca> Date: Thu, 24 Apr 2008 09:16:03 -0400 From: Frank Bax User-Agent: Thunderbird 2.0.0.6 (X11/20070818) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: First day of month, last day of month References: <481085D1.2010807@sympatico.ca> In-Reply-To: <481085D1.2010807@sympatico.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/153 X-Sequence-Number: 30692 Frank Bax wrote: > Nacef LABIDI wrote: >> is there a better method to retrieve all the rows with dates in the >> current month. > > > select * from mytable where extract(month from mydate) = extract(month > from now()) and extract(year from mydate) = extract(year from now()); Sorry; I was not thinking clearly - date_trunc is better for this: select * from mytable where date_trunc('month',mydate) = date_trunc('month',now());