Re: extract (dow/week from date) - Mailing list pgsql-general

From Tom Lane
Subject Re: extract (dow/week from date)
Date
Msg-id 22711.1124636045@sss.pgh.pa.us
Whole thread Raw
In response to Re: extract (dow/week from date)  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Responses Re: extract (dow/week from date)  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Re: extract (dow/week from date)  (Clodoaldo Pinto <clodoaldo.pinto@gmail.com>)
List pgsql-general
Stephan Szabo <sszabo@megazone.bigpanda.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

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: extract (dow/week from date)
Next
From: Stephan Szabo
Date:
Subject: Re: extract (dow/week from date)