From: | Jorge Godoy <jgodoy(at)gmail(dot)com> |
---|---|
To: | Bruno Wolff III <bruno(at)wolff(dot)to> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Setting week starting day |
Date: | 2007-03-10 02:07:26 |
Message-ID: | 877itpc0m9.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 20:13:11 -0300,
> Jorge Godoy <jgodoy(at)gmail(dot)com> wrote:
>> Bruno Wolff III <bruno(at)wolff(dot)to> writes:
>>
>> > No, it has to be inside the function so that the modular arithmetic is
>> > applied to it.
>>
>> Then there's the error I've shown from your command. Can you give me a
>> working one? This was with PostgreSQL 8.2.3.
>
> postgres=# select date_trunc('week', current_date + 1);
> date_trunc
> ------------------------
> 2007-03-05 00:00:00-06
> (1 row)
>
> It turns out DOW isn't available for date_trunc. You can probably use
> extract to get what you want. You probably should check that it works
> at DST transitions, since the date value is cast to a timestamp and
> if DST transitions happen at 0000 in your time zone, you might get an
> unexpected answer.
>
> postgres=# select extract(dow from current_date + 1);
> date_part
> -----------
> 6
> (1 row)
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.
--
Jorge Godoy <jgodoy(at)gmail(dot)com>
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2007-03-10 02:12:53 | Re: Setting week starting day |
Previous Message | Tom Lane | 2007-03-10 02:04:40 | Re: HIPPA (was Re: Anyone know ...) |