tags:

views:

422

answers:

4

How do I format a number to look like this: 9,000 my database field is in money data type, when I pull it up I see it like this: 9000.0000 that don't look right to me (I would like it to look like a real money format)

Sorry folks, forgot to mention technology it would be in C#

Thanks!

+3  A: 
decimal money = 1000;
Response.Write(string.Format("{0:C}", money));

The above is an example in C#.

Jon
Response.Write(string.Format("{0:C}", money)) would also be the equivalent in VB .NET since its really the framework doing the formatting, not the language
Joseph
A: 

You need to do a "formatting" function (in whatever language you're using) that will return the data in a currency format. Another answer already describes the code in C#. Here's vbscript:

Dim Amount
Amount = 2000
Response.Write(FormatCurrency(Amount))

How your database viewing application reads the data and how it is actually stored in the database may be two different things.

T Pops
+2  A: 

While you could call string.format, I think it's easier to just call ToString on it.

decimal money = 9000m;
string formattedMoney = money.ToString("C");
R. Bemrose