Re: cast numeric to char

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: cast numeric to char
Date: 2002-10-29 08:03:28
Message-ID: 20021029090327.G31118@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 28, 2002 at 10:13:02AM -0500, Johnson, Shaunn wrote:
> Yes, you cannot cast a numeric to character, but there is a function called
> to_char() that will help.
>
> Something like:
>
> planning=# select to_char(4, '0000009');
> to_char
> ----------
> 0000004
>
> The only annoying thing is that it seems to put a blank in front of the
> string, I am not sure why. You will probably want to trim() the results.

test=# select to_char(4, '99999999');
to_char
-----------
4

test=# select to_char(4, 'FM99999999');
to_char
---------
4

See docs, it's better then trim() :-)

Karel

--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christoph Dalitz 2002-10-29 08:10:27 Re: supplying password to psql on command line?
Previous Message Christoph Dalitz 2002-10-29 07:52:12 Re: supplying password to psql on command line?