From: | Dmitriy Igrishin <dmitigr(at)gmail(dot)com> |
---|---|
To: | Sim Zacks <sim(at)compulab(dot)co(dot)il> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Why length(to_char(1::integer, '9')) = 2 ? |
Date: | 2011-03-09 13:34:41 |
Message-ID: | AANLkTin3RK0zzdzYODsy3Bag_NW0bSNOBHzM_W4e_Fn=@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2011/3/9 Sim Zacks <sim(at)compulab(dot)co(dot)il>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 03/09/2011 03:12 PM, Dmitriy Igrishin wrote:
>
> > Hey all,
> >
> > dmitigr=> select to_char(1, '9');
> > to_char
> > ---------
> > 1
> >
> > dmitigr=> select length(to_char(1, '9'));
> > length
> > --------
> > 2
> >
> > Why to_char() includes preceding blank space in the result ?
> >
> > --
> > // Dmitriy.
> >
> >
> I don't know why, but to work around it use:
> select to_char(1, 'FM9');
> select length(to_char(1, 'FM9'));
>
Thanks!
But I am missing something or there is a documentation inaccuracy:
http://www.postgresql.org/docs/9.0/static/functions-formatting.html#FUNCTIONS-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?
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJNd3/JAAoJEHr2Gm0ENObOsUMH/ApWyfc5c5A56m1pAP7raIEd
> dmY0/aocCCnQbariREZIGSJPrmcWDKnNe3yNLjV2Y3+EY+eaicxy2GPTVamOrfqN
> tYQ/ImH3IkrzQk1bfRX+lnUJQGEmMi8ClzAatKUIifGJwMuj7y1xUl/VBTP0lBvI
> GuQQaElNkpGaPRTJZlorrtqEBgWmiyBT07gK02IST9xFsUPnrF0niNlqcaphF2Ga
> kKgFfVJ8u/C3KbwowVPh5GYZHgIM1T8x6SPzpcsnFVrIGN+avnuvdEInxomCZDNN
> FLuRBEPK9NFTG6rdIyrtfy5C6HVm/q7rO1alW0hjuszou1t2gBCOkmXtva9V5gY=
> =pGTI
> -----END PGP SIGNATURE-----
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
--
// Dmitriy.
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Farber | 2011-03-09 13:47:46 | Copying data from one table to another - how to specify fields? |
Previous Message | Dmitriy Igrishin | 2011-03-09 13:31:15 | Re: Why length(to_char(1::integer, '9')) = 2 ? |