Link to home
Start Free TrialLog in
Avatar of orther
orther

asked on

SQL Reporting format Phone Field

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
ASKER CERTIFIED SOLUTION
Avatar of sureshbabukrish
sureshbabukrish
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or this:

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

ASKER

Fast too