Re: Why length(to_char(1::integer, '9')) = 2 ? - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Why length(to_char(1::integer, '9')) = 2 ?
Date
Msg-id 201103090742.13601.adrian.klaver@gmail.com
Whole thread Raw
In response to Re: Why length(to_char(1::integer, '9')) = 2 ?  (Dmitriy Igrishin <dmitigr@gmail.com>)
Responses Re: Why length(to_char(1::integer, '9')) = 2 ?  (Dmitriy Igrishin <dmitigr@gmail.com>)
List pgsql-general
On Wednesday, March 09, 2011 5:34:41 am Dmitriy Igrishin wrote:

>
> But I am missing something or there is a documentation inaccuracy:
> http://www.postgresql.org/docs/9.0/static/functions-formatting.html#FUNCTIO
> NS-FORMATTING-NUMERICMOD-TABLEsays: fill mode (suppress padding blanks and
> zeroes)
>
> Test:
> dmitigr=> select to_char(12,'FM0009');
>  to_char
> ---------
>  0012
>
> dmitigr=> select length(to_char(12,'FM0009'));
>  length
> --------
>       4
>
> So, FM suppresses only padding blanks not zeroes...
>
> Any comments?
>

test(5432)aklaver=>select to_char(12,'9999');
 to_char
---------
    12

test(5432)aklaver=>select to_char(12,'FM9999');
 to_char
---------
 12

It is a little confusing, but you asked for the 0 in your specification so they
are not considered padding.

Look at the examples in the table listed below to get an idea of what I am
talking about.
http://www.postgresql.org/docs/9.0/static/functions-formatting.html
Table 9-25


--
Adrian Klaver
adrian.klaver@gmail.com

pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: FW: backup using pg_dump postgreSQL 8.3.8
Next
From: John Edens
Date:
Subject: How to configure for remote TCP/IP client conncections using MS Visual Basic OLE DB calls and PostgreSQL dll's?