Re: Setting week starting day

From: Jorge Godoy <jgodoy(at)gmail(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Jorge Godoy <jgodoy(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Setting week starting day
Date: 2007-03-09 19:44:57
Message-ID: 87ps7igq12.fsf@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruno Wolff III <bruno(at)wolff(dot)to> writes:

> On Fri, Mar 09, 2007 at 14:59:35 -0300,
> Jorge Godoy <jgodoy(at)gmail(dot)com> wrote:
>> It is not hard to calculate, as you can see... but it would be nice if
>> "date_trunc('week', date)" could do that directly. Even if it became
>> "date_trunc('week', date, 4)" or "date_trunc('week', date, 'Wednesday')" it
>> would be nice... :-) And that is what I was trying to ask ;-)
>
> Use date_trunc('week', current_day + 1) and date_trunc('dow', current_day + 1)
> to have a one day offset from the standard first day of the week.

I believe there's more than that... Probably the "+1" should be outside the
date_trunc, anyway. It might help, but I still see the need to to do
calculations... Specially if it was Tuesday today...

neo=# select date_trunc('dow', current_date + 1);
ERRO: unidades de timestamp with time zone "dow" são desconhecidas
neo=# select date_part('dow', current_date + 1);
date_part
-----------
6
(1 row)

neo=# select date_trunc('week', current_date + 1);
date_trunc
------------------------
2007-03-05 00:00:00-03
(1 row)

neo=# select date_trunc('week', current_date);
date_trunc
------------------------
2007-03-05 00:00:00-03
(1 row)

neo=#

--
Jorge Godoy <jgodoy(at)gmail(dot)com>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moseley 2007-03-09 19:45:40 Trigger for Audit Table
Previous Message Brandon Aiken 2007-03-09 19:35:23 Re: Anyone know a good opensource CRM that actually installs with Posgtres?