2011/3/9 Adrian Klaver <adrian.klaver@xxxxxxxxx>
On 03/09/2011 09:59 AM, Dmitriy Igrishin wrote:
<mailto: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.
 Âhttp://www.postgresql.org/docs/9.0/static/functions-formatting.html
 Â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)".
To get technical it means suppress unspecified padding O's. See below for example.This combination from the example table shows that:
Or I misunderstood what is "padding zeroes" without explicitly
specification "0" pattern in the format format template...
to_char(-0.1, 'FM9.99') '-.1'
to_char(0.1, '0.9') Â Â ' 0.1'
The 0 in 0.1 is not strictly needed, so if you use FM it will be suppressed.
Ahh, I guess I understand (thanks to you examples).
Lets look at the test:
dmitigr=> SELECT '>'||to_char(-0.1, 'FM9.99')||'<' AS v;
ÂÂ vÂÂ
-------
Â>-.1<
dmitigr=> SELECT '>'||to_char(0.1, '0.9')||'<' AS v;
ÂÂ vÂÂÂ
--------
Â> 0.1<
dmitigr=> SELECT '>'||to_char(0.1, 'FM0.9')||'<' AS v;
ÂÂ vÂÂ
-------
Â>0.1<
dmitigr=> SELECT '>'||to_char(0.1, '0.99999')||'<' AS v;
ÂÂÂÂ vÂÂÂÂÂ
------------
Â> 0.10000<
dmitigr=> SELECT '>'||to_char(0.1, 'FM0.99999')||'<' AS v;
ÂÂ vÂÂ
-------
Â>0.1<
So, padding zeroes suppressed by FM is a rest of the value.
Thank you very much!
Â
Lets look at the test:
dmitigr=> SELECT '>'||to_char(-0.1, 'FM9.99')||'<' AS v;
ÂÂ vÂÂ
-------
Â>-.1<
dmitigr=> SELECT '>'||to_char(0.1, '0.9')||'<' AS v;
ÂÂ vÂÂÂ
--------
Â> 0.1<
dmitigr=> SELECT '>'||to_char(0.1, 'FM0.9')||'<' AS v;
ÂÂ vÂÂ
-------
Â>0.1<
dmitigr=> SELECT '>'||to_char(0.1, '0.99999')||'<' AS v;
ÂÂÂÂ vÂÂÂÂÂ
------------
Â> 0.10000<
dmitigr=> SELECT '>'||to_char(0.1, 'FM0.99999')||'<' AS v;
ÂÂ vÂÂ
-------
Â>0.1<
So, padding zeroes suppressed by FM is a rest of the value.
Thank you very much!
Â
 Â--
 ÂAdrian Klaver
 Âadrian.klaver@xxxxxxxxx <mailto:adrian.klaver@xxxxxxxxx>
--
// Dmitriy.
--
--
// Dmitriy.