Skip site navigation (1) Skip section navigation (2)

Re: select to_number('1,000', '999,999');

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: David Schweikert <dws(at)ee(dot)ethz(dot)ch>, pgsql-bugs(at)postgresql(dot)org,Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Subject: Re: select to_number('1,000', '999,999');
Date: 2004-11-22 16:08:56
Message-ID: 15875.1101139736@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> No, but I think you're supposed to use FM in such cases.
>
> select to_number(1000, 'FM999,999');

Good point --- I had forgot about FM.  In that case there *is* a bug
here, but I'm not sure if it's with to_char or to_number:

regression=# select to_number(to_char(1000, 'FM999,999'),'FM999,999');
 to_number
-----------
      1000
(1 row)

regression=# select to_number(to_char(1000, '999,999'),'999,999');
 to_number
-----------
       100
(1 row)

Whatever your opinion is about the behavior of the non-FM format, surely
to_char and to_number should be inverses.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: IvanDate: 2004-11-22 17:11:01
Subject: Re: Data corruption/loss when altering tables (fwd)
Previous:From: David SchweikertDate: 2004-11-22 14:25:58
Subject: Re: select to_number('1,000', '999,999');

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group