On Thu, Sep 26, 2002 at 18:56:46 +0800, "John Sebastian N. Mayordomo" <quadratini@sni.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)