From: Robert Blixt <robert.blixt@transpa.se>
To: 'Janning Vygen' <vygen@planwerk6.de>
To: pgsql-sql@postgresql.org
Subject: Re: Extract week from date, start with sunday
Date: Tue, 8 Nov 2005 07:52:57 +0100
Message-ID: <20051108065256.7DFE7D7971@svr1.postgresql.org> (raw)
In-Reply-To: <200511071517.32435.vygen@planwerk6.de>
> -----Ursprungligt meddelande-----
> Från: Janning Vygen [mailto:vygen@planwerk6.de]
> Skickat: den 7 november 2005 15:18
> Till: pgsql-sql@postgresql.org
> Kopia: Robert Blixt
> Ämne: Re: [SQL] Extract week from date, start with sunday
>
> Am Montag, 7. November 2005 14:47 schrieb Robert Blixt:
> > Hi,
> >
> >
> > I am currently extracting my weeks from a date like this..
> >
> > SELECT INTO extractweek EXTRACT( week FROM ldate );
> >
> > This works fine, except that this assumes (according
> > to ISO standard) that weeks starts with Monday.
> >
> > I need the weeks to start with Sunday instead, otherwise
> > I will not get the correct week.
> >
> > Is there a workaround for this?
>
> calculation of weeks is not easy, but it should work like this to get a
> non-ISO week number:
>
> SELECT INTO extractweek EXTRACT( week FROM (ldate + '1 day'::interval));
>
> But its is just a guess. Because i dont know anything about your non-ISO
> rules. In which week is 2006-01-01? ISO Week 52/2005. Why dont you just
> take
> ISO Weeks. It's a standard. That's a good thing.
>
> kind regards
> Janning
>
> --
> PLANWERK 6 websolutions
> Herzogstraße 85, 40215 Düsseldorf
> Tel.: 0211-6015919 Fax: 0211-6015917
> http://www.planwerk6.de/
Thanks everyone for your help, adding a day
to the date does seem to do the trick.
I would certainly prefer to use the ISO standard.
However, the business sector that we develop for
use their standard weeks from Sun - Sat, so it isn't
really an option for us.
Thanks again everyone.
Kind Regards,
Robert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: robert.blixt@transpa.se, vygen@planwerk6.de
Subject: Re: Extract week from date, start with sunday
In-Reply-To: <20051108065256.7DFE7D7971@svr1.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox