Click here to Skip to main content
Click here to Skip to main content

Display number or amount with commas but no decimal places or extension displayed

By , 5 Jul 2012
 

Introduction

This post discusses how to display number or amount with commas, but no decimal places or extension displayed.

Here's the scenario:

I searched for awhile on how could I eliminate the decimal places on a particular field, but not remove the commas.

Like this: 234345455.89

Desired Output: 234,345,456

PARSENAME(CONVERT(varchar, CONVERT(money,txtSparkVolume), 1), 2) as txtSparkVolume,  

Using the Code

Here is the solution I made:
DECLARE txtGasVolume as float
SET GasVolume  =  234345455.89
PARSENAME(CONVERT(varchar, CONVERT(money,GasVolume), 1), 2) as cGasVolume 

I hope this helps. Thank you and God bless.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

jesureno
United States United States
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralThoughtsmemberPIEBALDconsult5 Jul '12 - 8:17 
You really ought to remove all the tags except SQL and maybe it only works with Microsoft's SQL Server.
The code provided doesn't seem to work (with MS SQL Server 2008).
Did you try ROUND ?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 5 Jul 2012
Article Copyright 2012 by jesureno
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid