Improve documentation of EXTRACT(WEEK).
authorTom Lane
Mon, 18 Mar 2013 17:34:15 +0000 (13:34 -0400)
committerTom Lane
Mon, 18 Mar 2013 17:34:15 +0000 (13:34 -0400)
The docs showed that early-January dates can be considered part of the
previous year for week-counting purposes, but failed to say explicitly
that late-December dates can also be considered part of the next year.
Fix that, and add a cross-reference to the "isoyear" field.  Per bug
#7967 from Pawel Kobylak.

doc/src/sgml/func.sgml

index 896c08c09cff7c50a1064a77e940e7b9731c23ad..51df17248a5ebad7d7fb144a396753bfdcad3d3e 100644 (file)
@@ -7151,16 +7151,19 @@ SELECT EXTRACT(SECOND FROM TIME '17:12:28.5');
       
        
         The number of the week of the year that the day is in.  By definition
-        (ISO 8601), the first week of a year
-        contains January 4 of that year.  (The ISO-8601
-        week starts on Monday.)  In other words, the first Thursday of
-        a year is in week 1 of that year.
+        (ISO 8601), 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.
        
        
-        Because of this, it is possible for early January dates to be part of the
-        52nd or 53rd week of the previous 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.
+        In the ISO definition, 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.