Skip to content

Commit 74ca686

Browse files
committed
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
1 parent 397831e commit 74ca686

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.86 2003/07/17 00:55:37 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.87 2003/07/26 15:17:36 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2533,7 +2533,7 @@ timestamp_trunc(PG_FUNCTION_ARGS)
25332533
case DTK_YEAR:
25342534
tm->tm_mon = 1;
25352535
case DTK_QUARTER:
2536-
tm->tm_mon = (3 * (tm->tm_mon / 4)) + 1;
2536+
tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1;
25372537
case DTK_MONTH:
25382538
tm->tm_mday = 1;
25392539
case DTK_DAY:
@@ -2626,7 +2626,7 @@ timestamptz_trunc(PG_FUNCTION_ARGS)
26262626
case DTK_YEAR:
26272627
tm->tm_mon = 1;
26282628
case DTK_QUARTER:
2629-
tm->tm_mon = (3 * (tm->tm_mon / 4)) + 1;
2629+
tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1;
26302630
case DTK_MONTH:
26312631
tm->tm_mday = 1;
26322632
case DTK_DAY:
@@ -2719,7 +2719,7 @@ interval_trunc(PG_FUNCTION_ARGS)
27192719
case DTK_YEAR:
27202720
tm->tm_mon = 0;
27212721
case DTK_QUARTER:
2722-
tm->tm_mon = (3 * (tm->tm_mon / 4));
2722+
tm->tm_mon = (3 * (tm->tm_mon / 3));
27232723
case DTK_MONTH:
27242724
tm->tm_mday = 0;
27252725
case DTK_DAY:
@@ -3297,7 +3297,7 @@ interval_part(PG_FUNCTION_ARGS)
32973297
break;
32983298

32993299
case DTK_QUARTER:
3300-
result = (tm->tm_mon / 4) + 1;
3300+
result = (tm->tm_mon / 3) + 1;
33013301
break;
33023302

33033303
case DTK_YEAR:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy