Re: start and end of the week - Mailing list pgsql-sql

From Dmitry Tkach
Subject Re: start and end of the week
Date
Msg-id 3D9335D1.4040807@openratings.com
Whole thread Raw
In response to Re: start and end of the week  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-sql
Does any one know what is the reason not to put this logic into date_trunc () function?
It seems to work with pretty much *any* unit imaginable, *except* for 'week'...

Dima

Bruno Wolff III wrote:
> On Thu, Sep 26, 2002 at 11:55:48 -0400,
>   Jean-Luc Lachance <jllachan@nsd.ca> 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.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 




pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: start and end of the week
Next
From: "Rajesh Kumar Mallah."
Date:
Subject: Re: check source of trigger