Solved

putting commas in numeric value for dollars

Posted on 2016-07-28
11
55 Views
Last Modified: 2016-07-29
I have a field i'm creating

cast (sum(tas.R12Value) as decimal (8,0)) as r12value

which is rounding the number for me fine.
1430022 however
I'm missing the commas ?
would like to see.
1,430,022

Thanks
fordraiders
0
Comment
Question by:fordraiders
  • 6
  • 4
11 Comments
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
>cast (sum(tas.R12Value) as decimal (8,0)) as r12value
>I'm missing the commas ?
That's because numeric data types such as int, decimal, numeric, etc. only store the number and not any cosmetic formatting such as currency symbols and thousands-separating commas.

Do your formatting in the presentiation (i.e. reporting) layer, not in the data layer.

So ... explain for us where you would 'like to see' the commas.
0
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
expressed in dollar amounts
12,000
1,000
13,248,765


etc...
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
That wasn't my question.  Where would you like to see these commas?  In the database, on a report, in an ETL feed, on a boat, with a goat, ...
0
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
dr suess...lol  

on asp.net c#  gridview
0
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
this is what I have thus far.

e.Row.Cells[3].Text = String.Format("$ {0:C}", e.Row.Cells[3].Text);
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 100 total points
Comment Utility
Ok.  In that case I recommend doing this in the formatting of the gridview.  Since I'm not an expert in either, I'll add those two zones to this question and step back so those experts can read your question and respond.
0
 
LVL 40

Accepted Solution

by:
Sharath earned 400 total points
Comment Utility
May be this.
convert(varchar,convert(money,sum(tas.R12Value)),1) AS r12value

Open in new window

0
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
sharath, perfect,...

Thanks !!
0
 
LVL 3

Author Closing Comment

by:fordraiders
Comment Utility
Thanks Sharath and
Jimbo, Thanx for the direction and help !!
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
Thanks for the split, but I'm going to recommend against the approach sharath posted.   If you convert these numbers to varchar in your data layer, then they will be varchar's in the reporting layer, which means the only way it will be able to participate in math such as addition, subtraction, subtotals, etc. is by implicit conversion, and the characters may (will?) cause it to throw an error.

Better to format in the report.
1
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
Jmbo, i tend to agree. Luckily this is just a one time view.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now