1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Fix wrong week returnded by date_trunc('week') for early dates in

January --- would return wrong year for 2005-01-01 and 2006-01-01.

per report from Robert Creager.

Backpatch to 8.0.X.
This commit is contained in:
Bruce Momjian
2005-04-01 14:25:23 +00:00
parent a70574d803
commit 9e9724e8bd
2 changed files with 34 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.243 2005/03/30 04:52:49 neilc Exp $
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.244 2005/04/01 14:25:22 momjian Exp $
PostgreSQL documentation
-->
@@ -5472,6 +5472,12 @@ SELECT EXTRACT(SECOND FROM TIME '17:12:28.5');
week starts on Monday.) In other words, the first Thursday of
a year is in week 1 of that year. (for <type>timestamp</type> values only)
</para>
<para>
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, <literal>2005-01-01</>
is part of the 53rd week of year 2004, and <literal>2006-01-01</> is part of
the 52nd week of year 2005.
</para>
<screen>
SELECT EXTRACT(WEEK FROM TIMESTAMP '2001-02-16 20:38:40');