timestamp date_trunc('quarter',...)
I corecting date_trunc('quarter',...) and friends because orig version
doing '2003-07-30' -> '2003-04-01', '2003-11-30' ->'2003-07-01'
Attachments:
postgresql-timestamp.patchtext/plain; name=postgresql-timestamp.patchDownload+4-4
Your patch has been added to the PostgreSQL unapplied patches list at:
http://momjian.postgresql.org/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
B���jthe Zolt���n wrote:
I corecting date_trunc('quarter',...) and friends because orig version
doing '2003-07-30' -> '2003-04-01', '2003-11-30' ->'2003-07-01'
--- src/backend/utils/adt/timestamp.c +++ src/backend/utils/adt/timestamp.c @@ -2412,7 +2412,7 @@ 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: @@ -2505,7 +2505,7 @@ 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: @@ -2598,7 +2598,7 @@ 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: @@ -3175,7 +3175,7 @@ break;case DTK_QUARTER: - result = (tm->tm_mon / 4) + 1; + result = (tm->tm_mon / 3) + 1; break;case DTK_YEAR:
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Patch applied. Thanks.
---------------------------------------------------------------------------
B���jthe Zolt���n wrote:
I corecting date_trunc('quarter',...) and friends because orig version
doing '2003-07-30' -> '2003-04-01', '2003-11-30' ->'2003-07-01'
--- src/backend/utils/adt/timestamp.c +++ src/backend/utils/adt/timestamp.c @@ -2412,7 +2412,7 @@ 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: @@ -2505,7 +2505,7 @@ 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: @@ -2598,7 +2598,7 @@ 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: @@ -3175,7 +3175,7 @@ break;case DTK_QUARTER: - result = (tm->tm_mon / 4) + 1; + result = (tm->tm_mon / 3) + 1; break;case DTK_YEAR:
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073