all groups > sql server reporting services > november 2005 >
You're in the

sql server reporting services

group:

format phone numbers


format phone numbers rybrown1818
11/28/2005 10:56:12 AM
sql server reporting services:
how can i format a phone number to be displayed as follows in the report
(678) 444-4444

Re: format phone numbers Alison
11/28/2005 1:18:36 PM

[quoted text, click to view]

Assuming all records are complete with 10 digits.
Try this:

=Format(cdec(PhoneNumber.Value),"(###) ###-####")

Re: format phone numbers Teo Lachev [MVP]
11/28/2005 9:56:45 PM
= Format(Convert.ToDouble("90155585850000"), "(###) ###-#### 'Ext.' ####")

or use a regular expression, sth like

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

--
HTH,
----------------------------------------------
Teo Lachev, MVP, MCSD, MCT
"Microsoft Reporting Services in Action"
"Applied Microsoft Analysis Services 2005"
Home page and blog: http://www.prologika.com/
----------------------------------------------
[quoted text, click to view]

Re: format phone numbers rybrown1818
11/29/2005 2:05:06 PM
okay great. I used the first example. Thanks!
Now i have discovered that there are some rows without phone numbers.
How do I do an IIF statement, that will return the formatted phone number
and not available when there is no phone number?

[quoted text, click to view]
Re: format phone numbers Teo Lachev [MVP]
11/29/2005 8:31:47 PM
=Iif (Fields!phone.Value Is Nothing, Nothing,
Format(Convert.ToDouble(Fields!phone.Value), "(###) ###-#### 'Ext.' ####"))

--
HTH,
----------------------------------------------
Teo Lachev, MVP, MCSD, MCT
"Microsoft Reporting Services in Action"
"Applied Microsoft Analysis Services 2005"
Home page and blog: http://www.prologika.com/
----------------------------------------------
[quoted text, click to view]

RE: format phone numbers rybrown1818
12/12/2005 11:10:04 AM
THANKS!!!!!!!!!

[quoted text, click to view]
Re: format phone numbers msflinx
10/20/2006 11:26:02 AM
OK -- this works to a point. I have real string data in my field that I want
to display if the field !isnumeric. So, here is the code I am using:

=iif(isnumeric(Fields!Q4Amt.Value),
Format(convert.ToDouble(Fields!Q4Amt.Value),
"$###,###,##0.00;($###,###,##0.00);$0.00"), "N/A")

Every time the N/A is supposed to be displayed, I get an error message.

Thanks for any and all help

[quoted text, click to view]
Re: format phone numbers msflinx
10/20/2006 12:24:01 PM
I'm not sure what I want right now. I want to be able to display the "N/A"
and $123,456.78 in the same textbox. So my options are:

1) If you cannot display a string and a number in the same textbox, can you
superimpose one textbox on top of another, with a switch as to the visible
textbox, based on the expression IsHidden =
iif(isnumeric(Fields!Q4Amt.Values),True, False

2) Write a parsing function in the Report Parameters Code window and return
ONLY string values

3) Punt....

Any other ideas would be appreciated.
[quoted text, click to view]
Re: format phone numbers msflinx
10/20/2006 12:43:01 PM
Thanks Chris. I posted this twice, as this thread did not move up the forum,
when I replied to it. I didn't think anyone was watching it.

The answer I received was option #2

This is the code I place in the Report Property's Code Tab:

Public Function NumericStringToCurrencyString(ByVal strPhrase as string) as
string

if isnumeric(strPhrase) then
NumericStringToCurrencyString =
format(cdec(strPhrase),"$###,###,###.##;($###,###,###.##);$0.00")
else
NumericStringToCurrencyString = strPhrase
end if

end function

Then in the textbox Expression field, I entered:

=Code.NumericStringToCurrencyString( Fields!Q4Amt.Value)

This gave me the desired results.

Thank you for your assistance
Thank you ever so much.

[quoted text, click to view]
Re: format phone numbers Chris Conner
10/20/2006 2:55:04 PM
You need to change the format of the textbox to be an expression - if the
value is NOT numeric, then the format is BLANK. You cannot dispaly regular
text for objects that are, in this case, formatted for numeric display.

Hope this helps.

=-Chris



[quoted text, click to view]

AddThis Social Bookmark Button