summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2003-07-26 15:17:36 +0000
committerBruce Momjian2003-07-26 15:17:36 +0000
commit74ca68679602306a430fb465e1bf4ac514551838 (patch)
treebd45bd278b5655c7d14c0268a06657605bbfe24e
parent397831e1039ecc335e1aae54ebea8483ce2e6b72 (diff)
I corecting date_trunc('quarter',...) and friends because orig version
doing '2003-07-30' -> '2003-04-01', '2003-11-30' ->'2003-07-01' B?jthe Zolt?n
-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 4ee6e953240..cef46084a1c 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.86 2003/07/17 00:55:37 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.87 2003/07/26 15:17:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2533,7 +2533,7 @@ timestamp_trunc(PG_FUNCTION_ARGS)
case DTK_YEAR:
tm->tm_mon = 1;
case DTK_QUARTER:
- tm->tm_mon = (3 * (tm->tm_mon / 4)) + 1;
+ tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1;
case DTK_MONTH:
tm->tm_mday = 1;
case DTK_DAY:
@@ -2626,7 +2626,7 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
case DTK_YEAR:
tm->tm_mon = 1;
case DTK_QUARTER:
- tm->tm_mon = (3 * (tm->tm_mon / 4)) + 1;
+ tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1;
case DTK_MONTH:
tm->tm_mday = 1;
case DTK_DAY:
@@ -2719,7 +2719,7 @@ interval_trunc(PG_FUNCTION_ARGS)
case DTK_YEAR:
tm->tm_mon = 0;
case DTK_QUARTER:
- tm->tm_mon = (3 * (tm->tm_mon / 4));
+ tm->tm_mon = (3 * (tm->tm_mon / 3));
case DTK_MONTH:
tm->tm_mday = 0;
case DTK_DAY:
@@ -3297,7 +3297,7 @@ interval_part(PG_FUNCTION_ARGS)
break;
case DTK_QUARTER:
- result = (tm->tm_mon / 4) + 1;
+ result = (tm->tm_mon / 3) + 1;
break;
case DTK_YEAR: