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

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

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: David Schweikert <dws(at)ee(dot)ethz(dot)ch>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: select to_number('1,000', '999,999');
Date: 2004-11-22 13:39:38
Message-ID: 20041122053847.U88957@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Mon, 22 Nov 2004, David Schweikert wrote:

> On Sun, Nov 21, 2004 at 20:10:08 -0500, Tom Lane wrote:
> > I'm not entirely convinced this is a bug.  I get the right answer from
> >
> > regression=# select to_number('001,000', '999,999') ;
> >  to_number
> > -----------
> >       1000
> > (1 row)
> >
> > It's arguable that to_number() should throw an error when the input
> > doesn't match the format, but right now it doesn't ...
>
> It seems strange to me that to_char(1000,'999,999') works (it returns
> 1,000), but the reverse doesn't.
>
> I want to convert a formatted number with group separators, but I don't
> know how many digits it has: should I count the digits myself and adapt
> the mask (which is a customization and thus entered by the user)?

No, but I think you're supposed to use FM in such cases.

select to_number(1000, 'FM999,999');

In response to

Responses

pgsql-bugs by date

Next:From: Stephan SzaboDate: 2004-11-22 13:47:19
Subject: Re: select to_number('1,000', '999,999');
Previous:From: PostgreSQL Bugs ListDate: 2004-11-22 12:50:41
Subject: BUG #1327: Compare column of varchar FAILURE!

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