Solved

lsnumberformat Question?

Posted on 2002-03-16
3
215 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
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 50 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

Free camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

Question has a verified solution.

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

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
A short film showing how OnPage and Connectwise integration works.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now