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
Solved

format of a number

Posted on 2015-01-13
4
87 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
  • 2
  • 2
4 Comments
 
LVL 28

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 28

Expert Comment

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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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