Search Postgresql Archives

Re: Why length(to_char(1::integer, '9')) = 2 ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





2011/3/9 Adrian Klaver <adrian.klaver@xxxxxxxxx>
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.
Table 9-25
Yes, I see, thanks!

I just talking about phrase "fill mode (suppress padding blanks and zeroes)"
in the documentation should be rephrased to "fill mode (suppress padding
blanks)".

Or I misunderstood what is "padding zeroes" without explicitly
specification "0" pattern in the format format template...


--
Adrian Klaver
adrian.klaver@xxxxxxxxx



--
// Dmitriy.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux