X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9EAABD79D9 for ; Tue, 8 Nov 2005 02:53:01 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75048-10 for ; Tue, 8 Nov 2005 06:52:59 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.mits.se (unknown [194.236.40.10]) by svr1.postgresql.org (Postfix) with ESMTP id 7DFE7D7971 for ; Tue, 8 Nov 2005 02:52:56 -0400 (AST) Received: from robertsdator ([192.168.0.27]) by mail.mits.se (mail.mits.se) with ESMTP id LRI73456; Tue, 8 Nov 2005 07:52:56 +0100 From: "Robert Blixt" To: "'Janning Vygen'" , Subject: Re: Extract week from date, start with sunday Date: Tue, 8 Nov 2005 07:52:57 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook, Build 11.0.6353 In-reply-to: <200511071517.32435.vygen@planwerk6.de> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcXjpbQQeePj6WA3Tg2xQp1XsLYDfwAiuY8w Message-Id: <20051108065256.7DFE7D7971@svr1.postgresql.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.927 required=5 tests=[MSGID_FROM_MTA_ID=0.927] X-Spam-Score: 0.927 X-Spam-Level: X-Archive-Number: 200511/66 X-Sequence-Number: 23317 > -----Ursprungligt meddelande----- > Fr=E5n: Janning Vygen [mailto:vygen@planwerk6.de] > Skickat: den 7 november 2005 15:18 > Till: pgsql-sql@postgresql.org > Kopia: Robert Blixt > =C4mne: Re: [SQL] Extract week from date, start with sunday >=20 > 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? >=20 > calculation of weeks is not easy, but it should work like this to get = a > non-ISO week number: >=20 > SELECT INTO extractweek EXTRACT( week FROM (ldate + '1 = day'::interval)); >=20 > 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. >=20 > kind regards > Janning >=20 > -- > PLANWERK 6 websolutions > Herzogstra=DFe 85, 40215 D=FCsseldorf > 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