Thread: to_char adds leading space, intended?

to_char adds leading space, intended?

From
"Aasmund Midttun Godal"
Date:
envisity=# SELECT '''' || to_char(1234, '099999') || '''';                           ?column?  
-----------' 001234'
(1 row)

Is this the way it's meant to be?

I would prefer 
'001234'

So I don't have to ltrim it.
Aasmund Midttun Godal

aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46


Re: to_char adds leading space, intended?

From
rolf.ostvik@axxessit.no
Date:
On 2002-01-03 "Aasmund Midttun Godal" <postgresql@envisity.com> wrote:
>envisity=# SELECT '''' || to_char(1234, '099999') || '''';

> ?column?
>-----------
> ' 001234'
>(1 row)

Modifier "FM" in the format string is your friend    SELECT '''' || to_char(1234, 'FM099999') || '''';
                ^^
 

Table 4.11 on    http://www.postgresql.org/idocs/index.php?functions-formatting.html
--
AXXESSIT ASA                  http://www.axxessit.no
Rolf Østvik / Test technician
Phone : (+47) 69 17 38 19     Fax: (+47) 69 17 39 00
P.O. Box 1053, Isebakkevn. 25, N-1787 Berg i Østfold