BUG #4523: TO_CHAR function : the ".US" format returns incorrect value

Started by Moussardover 17 years ago2 messagesbugs
Jump to latest
#1Moussard
evelyne.moussard@cartes-bancaires.com

The following bug has been logged online:

Bug reference: 4523
Logged by: Moussard
Email address: evelyne.moussard@cartes-bancaires.com
PostgreSQL version: 8.3.3
Operating system: i686-redhat-linux-gnu
Description: TO_CHAR function : the ".US" format returns incorrect
value
Details:

Using the "TO_CHAR" function, the ".US" format doesn't display the correct
value for the microseconds part of a timestamp value.

For exemple :

CREATE TABLE TITEST
(
DH_DEBUT TIMESTAMP(0),
TS_DEBUT TIMESTAMP(6),
D_DEBUT DATE
)
WITH (FILLFACTOR = 90);

truncate table titest;
insert into titest (ts_debut) values ('31/12/2008 23:59:58.123457');

select ts_debut from titest;

Returns the correct value : 2008-12-31 23:59:58.123457

select to_char(ts_debut,'dd/mm/yyyy HH24:MI:SS.US') from titest;

Returns a wrong value : 31/12/2008 23:59:58.123456
(the last number is not correct : 6 instead of 7).

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Moussard (#1)
Re: BUG #4523: TO_CHAR function : the ".US" format returns incorrect value

"Moussard" <evelyne.moussard@cartes-bancaires.com> writes:

Using the "TO_CHAR" function, the ".US" format doesn't display the correct
value for the microseconds part of a timestamp value.

If you're using floating-point timestamps, this isn't a bug --- it's
just inevitable platform-specific roundoff error. The particular test
case works as expected on the two machines I tried it on, but that
doesn't prove much of anything.

regards, tom lane