From: Jorge Godoy <jgodoy@gmail.com>
To: Ireneusz Pluta <ipluta@wp.pl>
Cc: Sergey Konoplev <gray.ru@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Week to date function
Date: Sat, 27 Mar 2010 15:08:53 -0300
Message-ID: <m2w175c742d1003271108p773ebaa7y4fedf008762ed12c@mail.gmail.com> (raw)
In-Reply-To: <4BAC9107.5070701@wp.pl>
References: <4BAB2C15.8090406@wp.pl>
<c3a7de1f1003250244p440b8244t57319b742fa680f0@mail.gmail.com>
<4BAC9107.5070701@wp.pl>
Are you sure?
http://en.wikipedia.org/wiki/ISO_8601
Week dates
Main article: ISO week date <http://en.wikipedia.org/wiki/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 – 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 53
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 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.
--
Jorge Godoy <jgodoy@gmail.com>
On Fri, Mar 26, 2010 at 07:48, Ireneusz Pluta <ipluta@wp.pl> wrote:
>
> Yes, much smarter.
> However, would give the same results on (year=2009, week=53) and
> (year=2010, week=1). In fact, 2009 did not have week 53.
> I wrapped it into a function with additional isoyear check and now seems
> OK.
>
> Thanks
>
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: jgodoy@gmail.com, ipluta@wp.pl, gray.ru@gmail.com
Subject: Re: Week to date function
In-Reply-To: <m2w175c742d1003271108p773ebaa7y4fedf008762ed12c@mail.gmail.com>
* 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