From: | Francisco Olarte <folarte(at)peoplecall(dot)com> |
---|---|
To: | maxk(at)yelp(dot)com |
Cc: | "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #13848: 2016 Week Number Error |
Date: | 2016-01-07 18:36:59 |
Message-ID: | CA+bJJbzghLjLXQFfUhgcKqQzJVUE=ZjqUUjgu_G44dcgusjQPQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Tue, Jan 5, 2016 at 8: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
If you did on Jan 5, it was correct.
RTFM, from http://www.postgresql.org/docs/9.4/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
>>>
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.
<<<
January 4 was a monday, so week from 4 to 10 is 1. 1,2,3 of jan belong
to week 53 of 2015 ( as even my dead-tree calendar shows ).
=> select extract(week from '2016-01-05'::date), extract(isoyear from
'2016-01-05'::date);
date_part | date_part
-----------+-----------
1 | 2016
(1 row)
=> select extract(week from '2016-01-01'::date), extract(isoyear from
'2016-01-01'::date);
date_part | date_part
-----------+-----------
53 | 2015
(1 row)
=> select extract(week from '2016-01-03'::date), extract(isoyear from
'2016-01-03'::date);
date_part | date_part
-----------+-----------
53 | 2015
(1 row)
=> select extract(week from '2016-01-04'::date), extract(isoyear from
'2016-01-04'::date);
date_part | date_part
-----------+-----------
1 | 2016
(1 row)
Francisco Olarte.
From | Date | Subject | |
---|---|---|---|
Next Message | John McKown | 2016-01-07 18:37:24 | Re: BUG #13848: 2016 Week Number Error |
Previous Message | NBoardman | 2016-01-07 16:14:34 | BUG #13853: initdb to UNC path |