Re: to_char() Question - Mailing list pgsql-general

From Terry Lee Tucker
Subject Re: to_char() Question
Date
Msg-id 200512141411.23742.terry@esc1.com
Whole thread Raw
In response to Re: to_char() Question  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general
Bruno,

Thanks for the response. The only problem is that FM removes all the leading
spaces. I may have been unclear in stating my problem. I want the padding on
the left; however, I don't want the extra space for the sign (+,-) that gets
prepended to the string. This output shows what I mean:
 rnd=# select to_char(1234, '"|"9999"|"');
 to_char
---------
 | 1234|
(1 row)
As you can see, not only do I get the four spaces I wanted, but I get one
additional. That is what I was trying to get rid of and John's solution
worked perfectly. It takes the extra space at the beginning out. I have a
couple overloaded functions handling this as well as ensuring that I'm not
dropping the negative sign on a number that actually is negative.

Anyway, thanks again for the response...

On Wednesday 14 December 2005 01:09 pm, Bruno Wolff III saith:
> On Tue, Dec 13, 2005 at 11:30:36 -0500,
>
>   Terry Lee Tucker <terry@esc1.com> wrote:
> > On Tuesday 13 December 2005 11:20 am, John Sidney-Woollett saith:
> > > Not sure if there is a numeric formatting option that allows what you
> > > want.
> > >
> > > But how about?
> > >
> > > substr(to_char(1029, '9,999'),2)
> >
> > That's so simple, I'm embarrased ;o)
> >
> > Thanks for the help...
>
> You can also us 'FM' to get rid of extra space. From the to_char docs:
> FM suppresses leading zeroes and trailing blanks that would otherwise be
> added to make the output of a pattern be fixed-width.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: to_char() Question
Next
From: Juan Jose Siles Salinas
Date:
Subject: Recuperar Base de datos