Re: Casting from varchar to numeric

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: tansley(at)law(dot)du(dot)edu, pgsql-novice(at)postgresql(dot)org
Subject: Re: Casting from varchar to numeric
Date: 2002-05-16 16:06:23
Message-ID: web-1461767@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Tom,

> 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?

Well, first off, you need to know the PostgreSQL conversion functions.
See the online documentation: Functions and Operators --> Formatting
Functions.

Second, if you check Roberto Mello's PL/pgSQL cookbook, you'll notice
that I posted a set of functions which auto-format phone numbers to US
spec.
http://www.brasileiro.net/postgres/cookbook/

It's under "String Manipulation Functions".

-Josh Berkus

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message gerry.smit 2002-05-16 16:11:12 Re: Answering my own question
Previous Message Adam Erickson 2002-05-16 15:56:46 Re: Answering my own question