Re: Casting from varchar to numeric - Mailing list pgsql-novice

From Tom Ansley
Subject Re: Casting from varchar to numeric
Date
Msg-id 200205161118.33795.tansley@law.du.edu
Whole thread Raw
In response to Casting from varchar to numeric  (Tom Ansley <tansley@law.du.edu>)
List pgsql-novice
Hi all,

ok...so the solution I currently have is to convert the varchar(10) into a
numeric value and then convert it back into a varchar but with all the bits
added.  This is my current code

to_char( to_number(hotel.main_phone, '9999999999') ,'(999)999-9999')

The problem with this is that I am getting a space between the first number
and the first bracket so it looks something like this....

( 999)999-9999

I have tried to get rid of the space using the MI template pattern but nothing
seems to work.

Does anybody have any ideas as to what is going wrong.

Cheers

Tom

On Thursday 16 May 2002 09:48 am, Tom Ansley wrote:
> Hi list,
>
> Is there a way of casting from a varchar to a numeric type?
>
> My problem consists of a varchar(10) that are all numeric.  They are
> telephone numbers and I want to convert them during a select statement to
> (XXX) XXX-XXXX
>
> Anybody have any ideas?
>
> Thanks
>
> Tom
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org


pgsql-novice by date:

Previous
From: gerry.smit@lombard.ca
Date:
Subject: Re: Trouble with index in 7.1
Next
From: "Joel Burton"
Date:
Subject: Re: Casting from varchar to numeric