Bug #733: Date Arithmetics within plsql

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #733: Date Arithmetics within plsql
Date: 2002-08-07 16:34:36
Message-ID: 20020807163436.EC516475C15@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Joerg Wedeck (joerg(dot)wedeck(at)datacare(dot)de) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Date Arithmetics within plsql

Long Description
Hi,

i have a problem with date arithmetics in plpgsql which i was able to track down into one simple function:

create function inc_date (date, interval) returns date as '
declare
help date;
begin
help := $1 + $2;
return help;
end;
' language 'plpgsql';

the following is the result:

jw=# select inc_date (date '2002-10-25', interval '1 day');
inc_date
------------
2002-10-26 -> ok
(1 row)

jw=# select inc_date (date '2002-10-25', interval '2 days');
inc_date
------------
2002-10-27 -> ok
(1 row)

jw=# select inc_date (date '2002-10-25', interval '3 days');
inc_date
------------
2002-10-27 -> oops ???? i would expect 2002-10-28
(1 row)

jw=# select inc_date (date '2002-10-25', interval '4 days');
inc_date
------------
2002-10-28
(1 row)

jw=# select inc_date (date '2002-10-25', interval '5 days');
inc_date
------------
2002-10-29
(1 row)

it happens only around the 27 th of october this year, on 26th next year ...

Version:
jw=# SELECT version();
version
---------------------------------------------------------------
PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4
(1 row)

jw=#

Installation:
package postgresql 7.2.1-2
debian/woody (same behavior on suse 8.0, redhat 7.3)

thank you, joerg

Sample Code

No file was uploaded with this report

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Nathan Suderman 2002-08-07 16:44:00 followup question Bug #476: pg_dump error: dtoi4: integer out of range
Previous Message Tom Lane 2002-08-07 13:55:19 Re: Bug #732: LIMIT clause bugs with insert...select