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-20 17:16:16
Message-ID: 200307201716.h6KHGGs00404@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


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.

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

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-20 17:52:32 Re: "fix" for plpgsql polymorphism
Previous Message Bruce Momjian 2003-07-20 04:36:48 Re: [HACKERS] allowed user/db variables