Solved

# format of a number

Posted on 2015-01-13
90 Views
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>
``````
0
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
• 2
• 2

LVL 29

Accepted Solution

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

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

ID: 40547205
Thank you for taking the time to help me.
0

LVL 29

Expert Comment

ID: 40547298
Thanks for the points
0

## Featured Post

Question has a verified solution.

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

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
###### Suggested Courses
Course of the Month4 days, 23 hours left to enroll