8000 Improve documentation of EXTRACT(WEEK). · commandprompt/postgres@a26e342 · GitHub
[go: up one dir, main page]

Skip to content

Commit a26e342

Browse files
committed
Improve documentation of EXTRACT(WEEK).
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.
1 parent 8d4bb31 commit a26e342

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

doc/src/sgml/func.sgml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6597,16 +6597,19 @@ SELECT EXTRACT(SECOND FROM TIME '17:12:28.5');
65976597
<listitem>
65986598
<para>
65996599
The number of the week of the year that the day is in. By definition
6600-
(<acronym>ISO</acronym> 8601), the first week of a year
6601-
contains January 4 of that year. (The <acronym>ISO</acronym>-8601
6602-
week starts on Monday.) In other words, the first Thursday of
6603-
a year is in week 1 of that year.
6600+
(<acronym>ISO</acronym> 8601), weeks start on Mondays and the first
6601+
week of a year contains January 4 of that year. In other words, the
6602+
first Thursday of a year is in week 1 of that year.
66046603
</para>
66056604
<para>
6606-
Because of this, it is possible for early January dates to be part of the
6607-
52nd or 53rd week of the previous year. For example, <literal>2005-01-01</>
6608-
is part of the 53rd week of year 2004, and <literal>2006-01-01</> is part of
6609-
the 52nd week of year 2005.
6605+
In the ISO definition, it is possible for early-January dates to be
6606+
part of the 52nd or 53rd week of the previous year, and for
6607+
late-December dates to be part of the first week of the next year.
6608+
For example, <literal>2005-01-01</> is part of the 53rd week of year
6609+
2004, and <literal>2006-01-01</> is part of the 52nd week of year
6610+
2005, while <literal>2012-12-31</> is part of the first week of 2013.
6611+
It's recommended to use the <literal>isoyear</> field together with
6612+
<literal>week</> to get consistent results.
66106613
</para>
66116614

66126615
<screen>

0 commit comments

Comments
 (0)
0