Re: to_char() Question

From: "John Sidney-Woollett" <johnsw(at)wardbrook(dot)com>
To: "Terry Lee Tucker" <terry(at)esc1(dot)com>
Cc: "PG-General General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: to_char() Question
Date: 2005-12-13 16:20:16
Message-ID: 8233.195.152.219.3.1134490816.squirrel@mercury.wardbrook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Not sure if there is a numeric formatting option that allows what you want.

But how about?

substr(to_char(1029, '9,999'),2)

John

Terry Lee Tucker said:
> Greetings List:
>
> I am using to_char to format numeric data into a string that is ultimately
> displayed in an XmText widget. Much of the numeric data is always going to
> be
> positive. In some of the windows that display this data, space is at a
> premium. Basically, I need to display something like 1,029 in an XmText
> widget that is exactly 5 characters wide. In a select statement like:
> SELECT to_char (1029, '9,999'), to_char always puts one extra space in the
> leftmost position for a numeric sign. What I get is: ' 1,029', which
> causes
> me to have to have the XmText widget 6 characters wide as opposed to 5.
> This
> is becoming a problem on several of the application windows where, as I
> said
> earlier, space is at a premium. The only way that I've been able to
> suppress
> the extra space is by the following: SELECT to_char (1029, 'FM9,999').
> What I
> get then is a string that is not right justified and I want the numbers to
> be
> right justified. Now, finally, the question: Is there a way to suppress
> the
> extra space for the sign?
>
> TIA
> rnd=# select version();
> version
> --------------------------------------------------------------------------------------------------------------
> PostgreSQL 7.4.6 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC)
> 3.2.3
> 20030502 (Red Hat Linux 3.2.3-49)
> (1 row)
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alex Mayrhofer 2005-12-13 16:20:41 Timestamp <-> ctime conversion question ...
Previous Message Stephen Frost 2005-12-13 16:06:13 Re: Bug#342369: PostgreSQL 8.1.0 RHEL / Debian incompatible