Re: Setting week starting day - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Setting week starting day
Date
Msg-id 20070310021253.GB24656@wolff.to
Whole thread Raw
In response to Re: Setting week starting day  (Jorge Godoy <jgodoy@gmail.com>)
Responses Re: Setting week starting day  (Omar Eljumaily <omar2@omnicode.com>)
Re: Setting week starting day  (Jorge Godoy <jgodoy@gmail.com>)
List pgsql-general
On Fri, Mar 09, 2007 at 23:07:26 -0300,
  Jorge Godoy <jgodoy@gmail.com> wrote:
>
> But how to get the date if the first day of the week is a Wednesday?  This
> example is like the ones I've sent with separate queries that needed being
> combined -- in a function, probably -- to get the desired result.

If you want to group on weeks that start on Wednesdays add 5.

postgres=# select date_trunc('week', '2007-03-07'::date + 5);
       date_trunc
------------------------
 2007-03-12 00:00:00-05
(1 row)

postgres=# select date_trunc('week', '2007-03-06'::date + 5);
       date_trunc
------------------------
 2007-03-05 00:00:00-06
(1 row)

postgres=# select date_trunc('week', '2007-03-08'::date + 5);
       date_trunc
------------------------
 2007-03-12 00:00:00-05
(1 row)

pgsql-general by date:

Previous
From: Jorge Godoy
Date:
Subject: Re: Setting week starting day
Next
From: Omar Eljumaily
Date:
Subject: Re: Setting week starting day