Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number Formatting 1

Status
Not open for further replies.

PetersWeb

Programmer
Apr 26, 2000
29
AU
I'd like to format numbers as phone numbers.&nbsp;&nbsp;For example 1234 456 789.&nbsp;&nbsp;My problem is the using #DateFormat(&quot;9999 999 999&quot;)# doesn't work.&nbsp;&nbsp;<br><br>The data is stored as 123456789. I've tried storing the numbers as text or numbers on various occasions without any change in the result.<br><br>Anybody got ideas? <p>Peter Toby<br><a href=mailto:webmaster@petertoby.com.au>webmaster@petertoby.com.au</a><br><a href= site is under construction
 
You could try<br><br>&lt;cfset xoutput=&quot;#left(x,4)# #mid(x,5,3)# #right(x,3)#&quot;&gt;<br>&lt;cfoutput&gt;#xoutput#&lt;/cfoutput&gt;
 
Thanks Darkman,<br><br>but this wasn't successful.<br><br>I didn't have the exact line of code I wanted to format.&nbsp;&nbsp;Here is the correct version:<br><br>#DateFormat(EmpList.mobile, &quot;9999 999 999&quot;)# <br><br>I'm trying to format staff's Mobile phone numbers on our Employee List.<br><br>Any suggestions appreciated.<br><br> <p>Peter Toby<br><a href=mailto:webmaster@petertoby.com.au>webmaster@petertoby.com.au</a><br><a href= site is under construction
 
I just tried:<br><FONT FACE=monospace><br>&lt;cfset EmpList.mobile=1234456789&gt;<br>&lt;cfset xoutput=&quot;#left(EmpList.mobile,4)# #mid(EmpList.mobile,5,3)# #right(EmpList.mobile,3)#&quot;&gt;<br>&lt;cfoutput&gt;#xoutput#&lt;/cfoutput&gt;<br></font><br>(There's spaces between the left, mid, and right functions) And it output 1234 456 789...<br><br>What I did notice is that the number you show as stored is 123456789 (nine digits) but the 1234 456 789 output you want is ten digits.&nbsp;&nbsp;In the above code I used 1234456789 (ten digits, notice the duplicated four), is this right, or should the fourth digit be duplicated?&nbsp;&nbsp;(I'm not familiar with Australian phone number coding, we Americans' phone numbers are formatted 999 999 9999)<br><br>Let me know...<br><br>DM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top