Re: extract (dow/week from date)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Clodoaldo Pinto <clodoaldo(dot)pinto(at)gmail(dot)com>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: extract (dow/week from date)
Date: 2005-08-21 14:54:05
Message-ID: 22711.1124636045@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> I think something like:
> (CASE WHEN extract(dow from date) = 0 THEN 7 else extract(dow from date))

It's really not that hard:

(extract(dow from date) + 6) % 7

You can rotate to any week-start day you like by substituting different
things for "6".

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2005-08-21 15:45:27 Re: extract (dow/week from date)
Previous Message Stephan Szabo 2005-08-21 14:32:59 Re: extract (dow/week from date)