Re: year and weeknumbers (proposal included)

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: joost(at)snow(dot)nl
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: year and weeknumbers (proposal included)
Date: 2003-01-30 14:28:55
Message-ID: 20030130142855.GA32517@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Jan 27, 2003 at 21:53:27 +0100,
joost(at)snow(dot)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.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Joost Helberg 2003-01-30 20:12:45 Re: year and weeknumbers (proposal included)
Previous Message Hans-Jürgen Schönig 2003-01-30 14:15:14 Re: year and weeknumbers (proposal included)