aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>2001-01-03 16:48:02 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>2001-01-03 16:48:02 +0000
commita8aa2f95b45a8ab95c489194f89c3bfcd4acf8cd (patch)
tree59b11d225a357386ec321cec6f4d066431b70147
parent39f987c568fcd54d82d7262f2a7273b7496ff205 (diff)
downloadpostgresql-a8aa2f95b45a8ab95c489194f89c3bfcd4acf8cd.tar.gz
postgresql-a8aa2f95b45a8ab95c489194f89c3bfcd4acf8cd.zip
Repair always-broken date_part('quarter',timestamp).
Previous result did not have correct month boundaries so anything near edge cases was suspect (e.g. April was in Q1 and July, August were lumped into Q2). Thanks to Denis Osadchy <osadchy@turbo.nsk.su> for the report.
-rw-r--r--src/backend/utils/adt/timestamp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 7ec213baab7..436eeb5b4da 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.40 2000/12/07 18:38:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.41 2001/01/03 16:48:02 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1887,9 +1887,9 @@ interval_trunc(PG_FUNCTION_ARGS)
}
/* isoweek2date()
- *
- * Convert ISO week of year number to date. An year must be already set.
- * karel 2000/08/07
+ * Convert ISO week of year number to date.
+ * The year field must be specified!
+ * karel 2000/08/07
*/
void
isoweek2date( int woy, int *year, int *mon, int *mday)
@@ -2053,7 +2053,7 @@ timestamp_part(PG_FUNCTION_ARGS)
break;
case DTK_QUARTER:
- result = (tm->tm_mon / 4) + 1;
+ result = ((tm->tm_mon - 1) / 3) + 1;
break;
case DTK_WEEK: