From: Bruno Wolff III <bruno@wolff.to>
To: Jean-Luc Lachance <jllachan@nsd.ca>
Cc: John Sebastian N. Mayordomo <quadratini@sni.ph>
Cc: Pgsql-Sql@Postgresql. Org <pgsql-sql@postgresql.org>
Subject: Re: start and end of the week
Date: Thu, 26 Sep 2002 11:20:29 -0500
Message-ID: <20020926162029.GA23728@wolff.to> (raw)
In-Reply-To: <3D932E04.F8D09FDF@nsd.ca>
References: <1033037809.16948.2.camel@tiger-work.sni.ph>
<3D932E04.F8D09FDF@nsd.ca>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bruno@wolff.to, jllachan@nsd.ca, quadratini@sni.ph
Subject: Re: start and end of the week
In-Reply-To: <20020926162029.GA23728@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox