65.9K
CodeProject is changing. Read more.
Home

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

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Jul 5, 2012

CPOL
viewsIcon

15773

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

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.