Telephone Format Coldfusion

Hi, All.  I think this is a coldfusion version problem.

I have the following code:
<input value="(#left(work_phone, 3)#) #right(left(work_phone, 6),3)# - #right(left(work_phone, 10),4)# <cfif len(work_phone) gt 10> ext. #right(left(work_phone, 14),4)#</cfif>" size="40" disabled="disabled" name="usnumber" type="text" />

This convert the data work_phone = 80012345678912 to (800) 123-4567 ext. 8912  

The code above works just fine in Coldfusion version 7 but when the same code is run on version 6, I get the following output,  (8.6) 123-4567 ext. 891E

Please help.  
jramos74Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

erikTsomikSystem Architect, CF programmer Commented:
it works fine for me
0
jramos74Author Commented:
I don't know what I am doing wrong.  The data type is set as number in the table.  It works fine on one server but it is calculating it on the different server.
0
erikTsomikSystem Architect, CF programmer Commented:
here what  i did. And it works on both versions


<cfoutput><cfset work_phone=000000000000000000000000000000>
<input value="(#left(work_phone, 3)#) #right(left(work_phone, 6),3)# - #right(left(work_phone, 10),4)# <cfif len(work_phone) gt 10> ext. #right(left(work_phone, 14),4)#</cfif>" size="40" disabled="disabled" name="usnumber" type="text" /></cfoutput>

Open in new window

0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

_agx_Commented:
Are you storing it as some type of floating point number?  That could cause a problem if the value is returned in scientific notation.  <Cfdump> the  #work_phone# value that is giving you trouble.  What is the value?
0
jramos74Author Commented:
Here is what I got  8.66644569466E+012
0
jramos74Author Commented:
How do I convert this data to string?  So I can use the phone format above?
0
_agx_Commented:
Yes, that's scientific notation.  A simple option is to convert the field to a varchar.
0
jramos74Author Commented:
Do I convert it from my query?
0
_agx_Commented:
Another option is to try converting the value to a varchar (ie string in your query)

SELECT  CAST(YourColumnName AS varchar(25)) AS WorkNumber
FROM    YourTable
....
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
erikTsomikSystem Architect, CF programmer Commented:
0
_agx_Commented:
> Do I convert it from my query?

Sorry our timing is off.  You could either convert it in your query -OR- change the data type of your table column. The first option is simpler, so try it first. The syntax may vary depending on your db.  What database (and version) are you using ?
0
jramos74Author Commented:
THANK YOU SO MUCH.  That worked.
0
_agx_Commented:
erikTsomik,

JavaCast is more for converting values passed into java classes.  You could use a separate java class to format the 8.66644569466E+012 value, but that is kind of overkill here.  I would try the simpler option (convert it in a query) first and use java only if that failed.
0
_agx_Commented:
jramos74,

Glad I could help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.