Skip to content

Great number formatting trick

July 24, 2009

An excellent use of Oracle’s inbuilt formatting function – much simpler than parsing the input and multiple concatenation operators:

SELECT TO_CHAR(0408211234, 'FM0000G000G000','nls_numeric_characters=.-') phone from dual;


SSN formatting with TO_CHAR

From → SQL

  1. Hi Jeffrey

    Your formatting trick is very clear and fine, but what to do if I want to have more complex mask based on various input strings ;)
    Please check out my query

    • Hi vkamys,

      I would probably use a CASE structure to select the appropriate format mask depending on the input.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 202 other followers

%d bloggers like this: