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

From Jorge Godoy
Subject Re: Setting week starting day
Date
Msg-id 877itqiddu.fsf@gmail.com
Whole thread Raw
In response to Re: Setting week starting day  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: Setting week starting day  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: Setting week starting day  (Omar Eljumaily <omar2@omnicode.com>)
List pgsql-general
Bruno Wolff III <bruno@wolff.to> writes:

> On Thu, Mar 08, 2007 at 20:32:22 -0300,
>   Jorge Godoy <jgodoy@gmail.com> wrote:
>> Alvaro Herrera <alvherre@commandprompt.com> writes:
>>
>> As I said, it is easy with a function. :-)  I was just curious to see if we
>> had something like Oracle's NEXT_DAY function or something like what I
>> described (SET BOW=4; -- makes Thursday the first day of week):
>
> If you are actually using "date" you can get the effect you want by adding
> a constant integer to the date in the date_trunc function. That seems
> pretty easy.


I couldn't see where to specify that integer.  Or, if it to sum it up to the
date, something that calculates it automatically.

http://www.postgresql.org/docs/8.2/interactive/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC

Adding an integer I'd still have to write the verifications (such as the one I
mention below for Oracle's NEXT_DATE()) to get the desired result.


Just to repeat my question:

(I don't want to write a function, I can do that pretty easily...  And I was
asking if there existed some feature on the database that...  It's just a
curiosity)

  Given a date X it would return me the first day of the week so that I can
  make this first day an arbitrary day, e.g. Friday or Wednesday.


Oracle's NEXT_DAY() gets closer to that, but would still require a few
operations (checking if the returned date is before the given date or if after
then subtract one week from this returned value, kind of a
"PREVIOUS_DATE()"...).


With a function I could make it easily, but then I'd have to wrap all
calculations with that...  It was just something to make life easier.  From
the answers I'm getting I see that there's no way to do that without a
function and that I'm not missing any feature on PG with regards to that ;-)

--
Jorge Godoy      <jgodoy@gmail.com>

pgsql-general by date:

Previous
From: Kevin Hunter
Date:
Subject: Re: HIPPA (was Re: Anyone know ...)
Next
From: Bill Moran
Date:
Subject: Re: HIPPA (was Re: Anyone know ...)