From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | lfrittelli(at)tutopia(dot)com, pgsql-bugs(at)postgresql(dot)org |
Cc: | Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu> |
Subject: | Re: Conversion errors for datetime fields |
Date: | 2000-12-28 16:28:14 |
Message-ID: | 5421.978020894@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
pgsql-bugs(at)postgresql(dot)org writes:
> 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)
What I'm getting with current sources is
regression=# select '0:00:59.99999999999999'::time as fourteen_dec;
fourteen_dec
--------------
00:00:59
(1 row)
which seems to be rounding in the wrong direction, and
regression=# select '0:00:59.999999999999999'::time as fifteen_dec;
ERROR: Bad time external representation '0:00:59.999999999999999'
That one seems reasonable, since this input is indistinguishable from
regression=# select '0:00:60'::time;
ERROR: Bad time external representation '0:00:60'
However, I also get
regression=# select now()::date+'0:00:59.999'::time;
?column?
---------------------------
2000-12-28 00:00:60.00-05
(1 row)
The cause is clear enough: the 59.999 seconds are being rounded off
to two digits for display. But it's unfortunate that this causes a
displayed output that will not be accepted as valid input. Perhaps
it would be a good idea to round off the seconds to display precision
*before* the value is broken down to hh/mm/ss.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Larry Rosenman | 2000-12-28 17:16:25 | Re: Conversion errors for datetime fields |
Previous Message | pgsql-bugs | 2000-12-28 15:55:52 | Conversion errors for datetime fields |