Re: BUG #13848: 2016 Week Number Error

From: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
To: maxk(at)yelp(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13848: 2016 Week Number Error
Date: 2016-01-07 18:37:24
Message-ID: CAAJSdjj6NrSoknbC-osBa-UAj3cTs8YbOc8JwdMmqi+nUM1EMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Jan 5, 2016 at 1:32 PM, <maxk(at)yelp(dot)com> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 13848
> Logged by: Max Kulinich
> Email address: maxk(at)yelp(dot)com
> PostgreSQL version: 9.4.5
> Operating system: OSX
> Description:
>
> SELECT EXTRACT(Week FROM current_date) = 1 instead of 2 Week numbers are
> all
> off
>

​This looks correct to me.

http://www.postgresql.org/docs/9.5/interactive/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
<quote>
week

The number of the ISO 8601 week-numbering week of the year. By definition,
ISO weeks start on Mondays and the first week of a year contains January 4
of that year. In other words, the first Thursday of a year is in week 1 of
that year.

In the ISO week-numbering system, it is possible for early-January dates to
be part of the 52nd or 53rd week of the previous year, and for
late-December dates to be part of the first week of the next year. For
example, 2005-01-01 is part of the 53rd week of year 2004, and 2006-01-01 is
part of the 52nd week of year 2005, while 2012-12-31 is part of the first
week of 2013. It's recommended to use the isoyear field together with week to
get consistent results.
</quote>

​Jan 1, 2016 was on ​a Friday. The first Thursday of 2016 is 7 Jan. ISO
calendars start on a Monday (unlike US calendars which start on a Sunday),
so the ISO first week of 2016 is Jan 4, 2016 to Jan 10, 2016.

--
Werner Heisenberg is driving down the autobahn. A police officer pulls
him over. The officer says, "Excuse me, sir, do you know how fast you
were going?"
"No," replies Dr. Heisenberg, "but I know where I am."

Computer Science is the only discipline in which we view adding a new wing
to a building as being maintenance -- Jim Horning

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

He's about as useful as a wax frying pan.

Maranatha! <><
John McKown

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-01-07 18:40:28 Re: BUG #13848: 2016 Week Number Error
Previous Message Francisco Olarte 2016-01-07 18:36:59 Re: BUG #13848: 2016 Week Number Error