?
Solved

SQL Reporting format Phone Field

Posted on 2011-05-12
3
Medium Priority
?
400 Views
Last Modified: 2012-05-11
I have a stored procedure that returns a a string as 12345678900000.  I use this stored procedure in my SQL Server Report.  I want to display it is the format as (123) 456-7890.

I found the following wihch returns the value: (123) 456-7890000

=System.Text.RegularExpressions.Regex.Replace(Fields!VendorPhone.Value, "(\d{3})[ -.]*(\d{3})[ -.]*(\d{4})", "($1) $2-$3")

What can i change in this value to only display the first 10 digits?  In other words, how can I drop the 4 remaining zeros?

How can I do this in the SQL Report?  We're using SQL 2008
0
Comment
Question by:orther
3 Comments
 
LVL 9

Accepted Solution

by:
sureshbabukrish earned 2000 total points
ID: 35744312
try this

System.Text.RegularExpressions.Regex.Replace(Left(Fields!VendorPhone.Value,10), "(\d{3})[ -.]*(\d{3})[ -.]*(\d{4})", "($1) $2-$3")

0
 
LVL 11

Expert Comment

by:shorak
ID: 35744331
or this:

=left(System.Text.RegularExpressions.Regex.Replace(Fields!VendorPhone.Value, "(\d{3})[ -.]*(\d{3})[ -.]*(\d{4})", "($1) $2-$3"),10)
0
 

Author Closing Comment

by:orther
ID: 35744335
Fast too
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this short article I will be talking about two functions in the SQL Server Reporting Services (SSRS) function stack.  Those functions are IIF() and Switch().  And I'll be showing you how easy it is to add an Else part to the Switch function. T…
How to use Variables  and Custom code in SSRS report and Assembly reference to use compile shared code in SSRS. Its big question for all who are working with SSRS. It is easy to create assembly and refer in SSRS report, still there are some steps…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question