Click here to Skip to main content
15,883,901 members
Articles / Programming Languages / SQL
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
5 Jul 2012CPOL 15.4K   3   1
Display number or amount with commas but no decimal places or extension displayed

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

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

Using the Code

Here is the solution I made:
SQL
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)


Written By
Software Developer (Senior) FLUOR
Philippines Philippines
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralThoughts Pin
PIEBALDconsult5-Jul-12 8:17
mvePIEBALDconsult5-Jul-12 8:17 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.