Conversion errors for datetime fields - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject Conversion errors for datetime fields
Date
Msg-id 200012281555.eBSFtq305583@hub.org
Whole thread Raw
Responses Re: Conversion errors for datetime fields  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Leonardo Frittelli (lfrittelli@tutopia.com) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Conversion errors for datetime fields

Long Description
I am currently using Postgresql version 7.0.2, but I did not find any reference to this problem in your bug/fix report
forrelease 7.0.3. 

I have noticed some conversion errors while using datetime/time fields with decimal values.
Here I send you two situations that I have been able to isolate.
I think that both are rounding errors.
I found these problems in Posgresql version 6.5.1 also, but it had been corrected in release 6.5.2. Now it has somehow
reappeared.


Sample Code
-- Situation Nr 1
create table foo(
  my_date datetime
);
insert into foo values (now()::date+'0:00:59.999999999999999'::time);
select my_date from foo;

-- Output from psql
--CREATE
--INSERT 90665 1
--          my_date
-----------------------------
-- 2000-12-28 00:01:60.00+00
--(1 row)
-- Note the '60 seconds' output

--------------------------------------------------------
-- Situation Nr 2

select '0:00:59.99999999999999'::time as fourteen_dec,
       '0:00:59.999999999999999'::time as fifteen_dec;

-- Output from psql
-- fourteen_dec | fifteen_dec
----------------+-------------
-- 00:00:59     | 00:00:00
--(1 row)
-- Note that in the second case the result is rounded down instead of up



No file was uploaded with this report

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: pg_toast_xxx table's file leak (grows indefinitely)
Next
From: Tom Lane
Date:
Subject: Re: Conversion errors for datetime fields