From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | "John Sebastian N(dot) Mayordomo" <quadratini(at)sni(dot)ph> |
Cc: | "Pgsql-Sql(at)Postgresql(dot) Org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: start and end of the week |
Date: | 2002-09-26 13:26:44 |
Message-ID: | 20020926132644.GA21571@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, Sep 26, 2002 at 18:56:46 +0800,
"John Sebastian N. Mayordomo" <quadratini(at)sni(dot)ph> wrote:
>
>
> How do I get the start and end date of the present week?
> Is this possible?
>
> For example this week
> Start = Sept. 22
> End = Sept. 28
The following advice will work on 7.3. For 7.2.2 and earlier it might
not work during a week with a timezone change depending at what time
of day you switch between DST and ST. To fix this you need to cast
current_date to a timestamp without timezone, and I haven't been
able to figure out how to do that and have to run off to a meeting now.
For the first day of the current week use something like:
area=> select current_date - extract(dow from current_date) *
area-> '1 day'::interval;
?column?
---------------------
2002-09-22 00:00:00
(1 row)
For the last day of the week use something like:
area=> select current_date + (6 - extract(dow from current_date)) *
area-> '1 day'::interval;
?column?
---------------------
2002-09-28 00:00:00
(1 row)
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Perrin | 2002-09-26 15:49:15 | Re: SQL formatter? |
Previous Message | John Sebastian N. Mayordomo | 2002-09-26 10:56:46 | start and end of the week |