Format Phone Number Text

R

R Keck

I'm having a difficult time accomplishing what I thought would be very simple
.....

I'm retriving a phone number field from a SQL server (nchar type) that has
only numbers (no parentheses or dashes) i.e. "1112223333"

In Access it is very simple to utilize the Format Funtion but I can't find
any coding that works in HTML to format the text.

I want to display ...
<%=FP_FieldVal(fp_rs,"PrimaryPhone")%>
as (111) 222-3333


Thanks
 
K

Kathleen Anderson [MVP - FrontPage]

In your SQL, you could do this:

FORMAT(PrimaryPhone,'(###) ###-####') as newPhone

newPhone will show up on your page.
 
R

R Keck

That function works fine, but I can not make it work in SQL server, either in
a view in the Server itself or in FP's SQL statement for the DB View.

From what i can gather, SQL does not recognize the FORMAT() function
 
S

Stefan B Rusynko

You could resort to inline string parsing
<% IF objRS("phone")<>"" Then %> Phone: (<%=Left(objRS("phone"),3) & ") " & Mid(objRS("phone"),4,3) & "-" &
Right(objRS("phone1"),4)%><%End If%>




| That function works fine, but I can not make it work in SQL server, either in
| a view in the Server itself or in FP's SQL statement for the DB View.
|
| From what i can gather, SQL does not recognize the FORMAT() function
|
| "Kathleen Anderson [MVP - FrontPage]" wrote:
|
| > In your SQL, you could do this:
| >
| > FORMAT(PrimaryPhone,'(###) ###-####') as newPhone
| >
| > newPhone will show up on your page.
| >
| >
| > --
| > ~ Kathleen Anderson
| > Microsoft MVP - FrontPage
| > Spider Web Woman Designs
| > web: http://www.spiderwebwoman.com/resources/
| >
| >
| > | > > I'm having a difficult time accomplishing what I thought would be very
| > > simple
| > > ....
| > >
| > > I'm retriving a phone number field from a SQL server (nchar type) that has
| > > only numbers (no parentheses or dashes) i.e. "1112223333"
| > >
| > > In Access it is very simple to utilize the Format Funtion but I can't find
| > > any coding that works in HTML to format the text.
| > >
| > > I want to display ...
| > > <%=FP_FieldVal(fp_rs,"PrimaryPhone")%>
| > > as (111) 222-3333
| > >
| > >
| > > Thanks
| >
| >
| >
 
Top