?
Solved

lsnumberformat Question?

Posted on 2002-03-16
3
Medium Priority
?
218 Views
Last Modified: 2013-12-24
Can someone help me in this code:

<cfoutput query="GetAllAnswers">
<cfif #GetTotalRespondees.TotalVotes# is not 0>
<cfset Percentage= lsnumberformat(((
#GetAllAnswers.Results#/
#GetTotalRespondees.TotalVotes#)*100),
"999.0")>
<cfelse>
<cfset Percentage= 0>
</cfif>

when i excute it, it gives me this error message "Cannot convert 49.0 to number.

Please, check the ColdFusion manual for the allowed conversions between data types"

Note 49 is the totall votes.
0
Comment
Question by:iqbalwali
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 200 total points
ID: 6874286
Perhaps it considers your data to be strings instead of numbers

Check it this way:
<cfoutput query="GetAllAnswers">
<cfif IsNumeric(GetTotalRespondees.TotalVotes) AND IsNumeric(GetAllAnswers.Results)
AND GetTotalRespondees.TotalVotes NEQ 0>
<cfset Percentage= lsnumberformat(((
GetAllAnswers.Results/
GetTotalRespondees.TotalVotes)*100),
"999.0")>
<cfelse>
  Numbers were either 0 or not numeric: #GetTotalRespondees.TotalVotes#,#GetAllAnswers.Results#<br>
<cfset Percentage= 0>
</cfif>
</cfoutput>
0
 

Author Comment

by:iqbalwali
ID: 6874986
Thanx budy!
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6875916
No problem.  Glad I could help and Thanx for the "A".
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question