Re: cast numeric to char - Mailing list pgsql-general

From Karel Zak
Subject Re: cast numeric to char
Date
Msg-id 20021029090327.G31118@zf.jcu.cz
Whole thread Raw
In response to Re: cast numeric to char  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
List 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@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

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

pgsql-general by date:

Previous
From: Christoph Dalitz
Date:
Subject: Re: supplying password to psql on command line?
Next
From: Christoph Dalitz
Date:
Subject: Re: supplying password to psql on command line?