Re: timestamp date_trunc('quarter',...)

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Böjthe Zoltán <zbojthe(at)arcinfo(dot)hu>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: timestamp date_trunc('quarter',...)
Date: 2003-07-26 15:17:40
Message-ID: 200307261517.h6QFHeR17650@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


Patch applied. Thanks.

---------------------------------------------------------------------------

Bjthe Zoltn 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(at)postgresql(dot)org

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-07-26 15:22:45 Re: [PATCHES] sslmode patch
Previous Message Tom Lane 2003-07-26 15:14:46 Re: [PATCHES] sslmode patch