Re: timestamp date_trunc('quarter',...) - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: timestamp date_trunc('quarter',...)
Date
Msg-id 200307201716.h6KHGGs00404@candle.pha.pa.us
Whole thread Raw
In response to timestamp date_trunc('quarter',...)  (Böjthe Zoltán <zbojthe@arcinfo.hu>)
List 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.

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


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

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] allowed user/db variables
Next
From: Bruce Momjian
Date:
Subject: Re: "fix" for plpgsql polymorphism