Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 7F0DB2E004B for ; Thu, 24 Apr 2008 13:39:22 -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 10868-01-3 for ; Thu, 24 Apr 2008 13:39:07 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.230]) by developer.postgresql.org (Postfix) with ESMTP id 8FC792E0061 for ; Thu, 24 Apr 2008 13:39:08 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id r21so2798660wxc.28 for ; Thu, 24 Apr 2008 09:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=kK8/iISw/VUcy8twO7Nun3C/GLjweAnBa2FidFkV29s=; b=FMcQx4ZHg+PYJr6swZzGWDv6Bvz5sC5hC1n7LKozRYkYXCVd/q8tyozDq/1Orv65QxmEku69Ek7vTcbqoOk5PNWB8loP2455zi+CgevG0pQ9g5VBuuzYLnKf2czi9vm8Ilp6BU062SkGriPLeSk4jcLCOF/GPm/LBoRGpqxgpDE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=fVMAHg++Jm1d5mW1b3+KxNDSLtMKzjBOmhKefQJ3i6hOeWSUy0+Dl/18TwJ9hdiXu7ZLsqR8dFYHxzeXiapqcZjjFUnZpCVVEs9RUNaEdkIGgWmr0sX2JpskoUnuqTp4N5ifE4Dr5Rbqcu0jNk42eaoqrxSxMQhUKAg7XxbFinY= Received: by 10.70.42.16 with SMTP id p16mr3717369wxp.14.1209055146781; Thu, 24 Apr 2008 09:39:06 -0700 (PDT) Received: by 10.70.25.5 with HTTP; Thu, 24 Apr 2008 09:39:06 -0700 (PDT) Message-ID: Date: Thu, 24 Apr 2008 18:39:06 +0200 From: "Nacef LABIDI" To: "A. Kretschmer" Subject: Re: First day of month, last day of month Cc: pgsql-sql@postgresql.org In-Reply-To: <20080424131536.GC15397@a-kretschmer.de> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_12803_3737840.1209055146769" References: <20080424131536.GC15397@a-kretschmer.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200804/173 X-Sequence-Number: 30712 ------=_Part_12803_3737840.1209055146769 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline It would be rather : test=*# select date_trunc('month', current_date), date_trunc('month', current_date)+'1month': > > :interval-'1sec'::interval; "2008-04-01 00:00:00+02";"2008-04-30 23:59:59+02" On Thu, Apr 24, 2008 at 3:15 PM, A. Kretschmer < andreas.kretschmer@schollglas.com> wrote: > am Thu, dem 24.04.2008, um 14:59:47 +0200 mailte Nacef LABIDI folgendes: > > Hi all, > > > > I want to select data from a table according to a date column in my > table. I > > want to select all the rows which have date in the current month. So is > there a > > way to get from the actual date the first day and the last day of the > month or > > test=*# select date_trunc('month', current_date), date_trunc('month', > current_date)+'1month'::interval-'1day'::interval; > date_trunc | ?column? > ------------------------+------------------------ > 2008-04-01 00:00:00+02 | 2008-04-30 00:00:00+02 > > > > -- > Andreas Kretschmer > Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) > GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > ------=_Part_12803_3737840.1209055146769 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline It would be rather :

test=*# select date_trunc('month', current_date), date_trunc('month', current_date)+'1month':
:interval-'1sec'::interval;

"2008-04-01 00:00:00+02";"2008-04-30 23:59:59+02"


On Thu, Apr 24, 2008 at 3:15 PM, A. Kretschmer <andreas.kretschmer@schollglas.com> wrote:
am  Thu, dem 24.04.2008, um 14:59:47 +0200 mailte Nacef LABIDI folgendes:
> Hi all,
>
> I want to select data from a table according to a date column in my table. I
> want to select all the rows which have date in the current month. So is there a
> way to get from the actual date the first day and the last day of the month or

test=*# select date_trunc('month', current_date), date_trunc('month', current_date)+'1month'::interval-'1day'::interval;
      date_trunc       |        ?column?
------------------------+------------------------
 2008-04-01 00:00:00+02 | 2008-04-30 00:00:00+02



--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

------=_Part_12803_3737840.1209055146769--