Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F034F476D3F for ; Thu, 26 Sep 2002 12:12:15 -0400 (EDT) Received: from wolff.to (wolff.to [66.93.197.35]) by postgresql.org (Postfix) with SMTP id 26714476D01 for ; Thu, 26 Sep 2002 12:12:15 -0400 (EDT) Received: (qmail 23841 invoked by uid 500); 26 Sep 2002 16:20:29 -0000 Date: Thu, 26 Sep 2002 11:20:29 -0500 From: Bruno Wolff III To: Jean-Luc Lachance Cc: "John Sebastian N. Mayordomo" , "Pgsql-Sql@Postgresql. Org" Subject: Re: start and end of the week Message-ID: <20020926162029.GA23728@wolff.to> Mail-Followup-To: Jean-Luc Lachance , "John Sebastian N. Mayordomo" , "Pgsql-Sql@Postgresql. Org" References: <1033037809.16948.2.camel@tiger-work.sni.ph> <3D932E04.F8D09FDF@nsd.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3D932E04.F8D09FDF@nsd.ca> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/326 X-Sequence-Number: 9603 On Thu, Sep 26, 2002 at 11:55:48 -0400, Jean-Luc Lachance wrote: > How about: > > select now() - date_part( 'DOW', now()) as starts_on, > now() -date_part( 'DOW', now()) + 6 as ends_on; That won't work in 7.3. The following works in both 7.2 and 7.3: area=> select current_date - extract(dow from current_date)::int as start_date, area-> current_date - extract(dow from current_date)::int + 6 as end_date; start_date | end_date ------------+------------ 2002-09-22 | 2002-09-28 (1 row) Extract returns double precision and so needs a cast to int to work.