Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 34BEB6347BB for ; Sat, 27 Mar 2010 15:10:45 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 22958-01-6 for ; Sat, 27 Mar 2010 18:10:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gy0-f174.google.com (mail-gy0-f174.google.com [209.85.160.174]) by mail.postgresql.org (Postfix) with ESMTP id 329726343D3 for ; Sat, 27 Mar 2010 15:09:14 -0300 (ADT) Received: by gyg13 with SMTP id 13so668270gyg.19 for ; Sat, 27 Mar 2010 11:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:cc:content-type; bh=GHFwRpY3Xa1nL8I5lRjQGYvByH57JRPP6MIhjifdCQY=; b=gBc0mHHEutXPeSMtSW5pv4foq94fdLNrBknkTb5PCvAxe8lR1FQFqS2r+wcQ8QUdWi YIzIdT9cJpBxmbtLOeUSncVFqtDRMb9LXCnSqIbDdquEW9rj128KTjLX4Xr4AtkSbfcp g6SU7An5mdr6zrWhZjD4B/1rNBi5cVVxnMMVY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=aW+xGnL5Mt/CD/ITd30tpMUr0jnBH0meW8iwlWYjLksjlSaUXqDnG93Wtw6jyW1omL EkAgD+Tu+SrKHozMk38Wu8kQDkbTa2fqC64ub1t2VEk/lnb/mXy7rZKDu6dVHCfU5lGV jtfUqZ6MqQtPg++8ULSmG2ByoMtAzilXqoyVc= MIME-Version: 1.0 Received: by 10.100.253.19 with HTTP; Sat, 27 Mar 2010 11:08:53 -0700 (PDT) In-Reply-To: <4BAC9107.5070701@wp.pl> References: <4BAB2C15.8090406@wp.pl> <4BAC9107.5070701@wp.pl> From: Jorge Godoy Date: Sat, 27 Mar 2010 15:08:53 -0300 Received: by 10.100.22.17 with SMTP id 17mr2356715anv.241.1269713353154; Sat, 27 Mar 2010 11:09:13 -0700 (PDT) Message-ID: Subject: Re: Week to date function To: Ireneusz Pluta Cc: Sergey Konoplev , pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=001485f897cc61a10d0482cc2da8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.002 tagged_above=-10 required=5 tests=BAYES_50=0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201003/207 X-Sequence-Number: 33914 --001485f897cc61a10d0482cc2da8 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Are you sure? http://en.wikipedia.org/wiki/ISO_8601 Week dates Main article: ISO week date *YYYY-Www* *or* *YYYYWww* *YYYY-Www-D* *or* *YYYYWwwD* Week date representations are in the format as shown in the box to the right. [YYYY] indicates the *ISO week-numbering year* which is slightly different to the calendar year (see below). [Www] is the *week number*prefixed by the letter 'W', from W01 through W53. [D] is the *weekday number*, from 1 through 7, beginning with Monday and ending with Sunday. This form is popular in the manufacturing industries. There are mutually equivalent descriptions of week 01: - the week with the year's first Thursday in it (the formal ISO definition), - the week with 4 January in it, - the first week with the majority (four or more) of its days in the starting year, and - the week starting with the Monday in the period 29 December =96 = 4 January. *If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01.* If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 5= 3 of the previous year (there is no week 00). 28 December is always in the last week of its year. The week number can be described by counting the Thursdays: week 12 contain= s the 12th Thursday of the year. In 2009, January 1st. happened on a Thursday. As Jan 1st, 2010 happened on a Friday, it was on week 53 of 2009. -- Jorge Godoy On Fri, Mar 26, 2010 at 07:48, Ireneusz Pluta wrote: > > Yes, much smarter. > However, would give the same results on (year=3D2009, week=3D53) and > (year=3D2010, week=3D1). In fact, 2009 did not have week 53. > I wrapped it into a function with additional isoyear check and now seems > OK. > > Thanks > --001485f897cc61a10d0482cc2da8 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Are you sure?


Week dates

<= table class=3D"infobox" style=3D"text-align: center; width: 25em;"> YYYY-Www or YYYYWww YYYY-Www-D or YYYYWwwD

We= ek date representations are in the format as shown in the box to=20 the right. [YYYY] indicates the ISO week-numbering year which is=20 slightly different to the calendar year (see below). [Www] is the week number prefixed by the letter 'W', from W01 through W53. [D] i= s the weekday number, from 1 through 7, beginning with Monday and=20 ending with Sunday. This form is popular in the manufacturing=20 industries.

The= re are mutually equivalent descriptions of week 01:

      • the week with the year's first Thursday in it (the formal I= SO=20 definition),
      • the week with 4 January in it,
      • the first week = with the majority (four or more) of its days in the=20 starting year, and
      • the week starting with the Monday in the period = 29 December =96 4=20 January.

<= b>If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in wee= k 52 or 53 of the previous year (there is no week 00). 28 December is=20 always in the last week of its year.

The week number can be described by counting the Thur= sdays: week 12=20 contains the 12th Thursday of the year.

=

In 2009, January 1st. happened on a Thursday.

As Jan 1st, 2010 happened on a Friday, it was on week 53 of= 2009.



--001485f897cc61a10d0482cc2da8--