Re: Casting from varchar to numeric

Поиск
Список
Период
Сортировка
От Tom Ansley
Тема Re: Casting from varchar to numeric
Дата
Msg-id 200205161118.33795.tansley@law.du.edu
обсуждение исходный текст
Ответ на Casting from varchar to numeric  (Tom Ansley <tansley@law.du.edu>)
Список 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 по дате отправления:

Предыдущее
От: gerry.smit@lombard.ca
Дата:
Сообщение: Re: Trouble with index in 7.1
Следующее
От: "Joel Burton"
Дата:
Сообщение: Re: Casting from varchar to numeric