Re: start and end of the week

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
Cc: "John Sebastian N(dot) Mayordomo" <quadratini(at)sni(dot)ph>, "Pgsql-Sql(at)Postgresql(dot) Org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: start and end of the week
Date: 2002-09-26 16:20:29
Message-ID: 20020926162029.GA23728@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Sep 26, 2002 at 11:55:48 -0400,
Jean-Luc Lachance <jllachan(at)nsd(dot)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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitry Tkach 2002-09-26 16:29:05 Re: start and end of the week
Previous Message Jean-Luc Lachance 2002-09-26 15:55:48 Re: start and end of the week