Solved

format of a number

Posted on 2015-01-13
4
88 Views
Last Modified: 2015-01-13
Hi,

How can I change this number from

output: 
5,300,000 - 6,500,000
400,000 - 700,000
450,000 - 250,000
but 

this is how I want the output to be:

5.3M - 6.5M 
400K - 700K
450K - 250K




   <cfoutput>#numberformat(GrandFrom2020,'999,999,999,999,999,999,999')#</cfoutput> -
          <cfoutput>#numberformat(GrandTo2020,'999,999,999,999,999,999,999')#</cfoutput>  

Open in new window

0
Comment
Question by:lulu50
[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
  • 2
4 Comments
 
LVL 29

Accepted Solution

by:
Pravin Asar earned 500 total points
ID: 40547188
Hope this works for you.

<cfset x=345000/>
<cfset y = 6500000/>
<cfscript>
      function MyFormatter(number) {
            formatDone = false;
            convertText= "K,M";
            convertFactore="1000,1000000";
            while (!formatDone) {
                  if (number/1000000 > 1) {
                        return "" & (number/1000000) & "M";
                  }
                  else if (number/1000 > 1) {
                        return "" & (number/1000) & "K";
                  }
                  else {
                        return number;
                  }
            }
      }

</cfscript>
<cfoutput>#myformatter(x)#</cfoutput>
<br/>

<cfoutput>#myformatter(y)#</cfoutput>
0
 

Author Comment

by:lulu50
ID: 40547204
Pravin

I don't know where to start to thank you

YOU ARE GREAT!!!

WOW What can I say!!!!!!

WOW AGAIN AND AGAIN

GOOD JOB!!!!!!
0
 

Author Closing Comment

by:lulu50
ID: 40547205
Thank you for taking the time to help me.
0
 
LVL 29

Expert Comment

by:Pravin Asar
ID: 40547298
Thanks for the points
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

735 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