| From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
|---|---|
| To: | Jorge Godoy <jgodoy(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Setting week starting day |
| Date: | 2007-03-10 02:12:53 |
| Message-ID: | 20070310021253.GB24656@wolff.to |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Fri, Mar 09, 2007 at 23:07:26 -0300,
Jorge Godoy <jgodoy(at)gmail(dot)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)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Omar Eljumaily | 2007-03-10 02:41:51 | Re: Setting week starting day |
| Previous Message | Jorge Godoy | 2007-03-10 02:07:26 | Re: Setting week starting day |