Re: problem with to_char - Mailing list pgsql-general

From Thomas Lockhart
Subject Re: problem with to_char
Date
Msg-id 3C56A008.E05D299@fourpalms.org
Whole thread Raw
In response to problem with to_char  (Carsten Grewe <DerReisende@schatzis.org>)
Responses Re: problem with to_char  (Karel Zak <zakkr@zf.jcu.cz>)
List pgsql-general
> I think I have not understood some elementary things of the to_char function
> in pgsql7.1.2. I only get back a mask instead of a formatted string.
> I tried the following in psql:
> SPS=> select to_char(45145, '9.999,99');
>   to_char
> -----------
>   #.###,##
> (1 row)

The number will not fit into the field you have defined, so it is filled
with hash marks to indicate overflow.

If your locale is not set up to recognize "european style" numbers, then
in this case you have defined a formatting string which allows only
numbers less than 10. If you are set up to recognize european formatting
(I'm not familiar with this for to_char(); see the docs) then you have
defined a formatting string with allows only numbers less than 9999,
which still won't hold the number you are asking it to format for you.

Try to_char(45145, '99,999.99') and to_char(45145, '99.999,99'); one of
them will work.

hth

                     - Thomas

pgsql-general by date:

Previous
From: "Ben-Nes Michael"
Date:
Subject: unique & update
Next
From: Frank Schafer
Date:
Subject: Re: unique & update