Re: year and weeknumbers (proposal included) - Mailing list pgsql-bugs

From Bruno Wolff III
Subject Re: year and weeknumbers (proposal included)
Date
Msg-id 20030130142855.GA32517@wolff.to
Whole thread Raw
In response to year and weeknumbers (proposal included)  (joost@snow.nl)
List pgsql-bugs
On Mon, Jan 27, 2003 at 21:53:27 +0100,
  joost@snow.nl wrote:
> hi,
>
> last year (2002) the date december 31st is in week 1 of 2003.
>
> it is not possible to get this out of a date-column using EXTRACT or
> to_char.
>          to_char( '2002-12-31', 'WW' ) returns 1, and
>          to_char( '2002-12-31', 'YYYY' ) returns 2002 (as expected)!

It is POSSIBLE to do. You can use the fact that the Thursday of a week
is always in the same year as the week number refers to, to get the
correct year. It isn't pretty though and it probably is a good idea to
have a simple way to get the year corresponding to an ISO week.

pgsql-bugs by date:

Previous
From: joost@snow.nl
Date:
Subject: year and weeknumbers (proposal included)
Next
From: Hans-Jürgen Schönig
Date:
Subject: Re: year and weeknumbers (proposal included)