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!
-
decimal money = 1000; Response.Write(string.Format("{0:C}", money));
The above is an example in C#.
Joseph : 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 -
These might help, Read'em.
http://www.onlamp.com/pub/a/onlamp/2001/09/13/aboutSQL.html http://www.informit.com/guides/content.aspx?g=sqlserver&seqNum=54
-
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.
-
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");
0 comments:
Post a Comment