Re: Extra space when converting number with to_char

From: Bosco Rama <postgres(at)boscorama(dot)com>
To: Samuel Gilbert <samuel(dot)gilbert(at)ec(dot)gc(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Extra space when converting number with to_char
Date: 2012-10-26 19:58:36
Message-ID: 508AEB6C.5000305@boscorama.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/26/12 11:50, Samuel Gilbert wrote:
>
> (SELECT to_char(42, '000000000') AS string) AS example;
>
> string | length | showthemtome
> ------------+--------+--------------
> 000000042 | 10 | " 000000042"

Sign padding. Try using:
select to_char(42, 'FM000000000') ...

To see why, look here:
http://www.postgresql.org/docs/9.2/static/functions-formatting.html#FUNCTIONS-FORMATTING-NUMERICMOD-TABLE

HTH

Bosco.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Moshe Jacobson 2012-10-26 20:01:08 Re: Extra space when converting number with to_char
Previous Message David Johnston 2012-10-26 19:23:50 Re: Extra space when converting number with to_char