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)
United States (U.S.) currency is formatted with a decimal point (.) as a separator between the dollars and cents. Some countries use a comma (,) instead of a decimal to indicate that separation.
In the Format sidebar, click the Cell tab, then click the Data Format pop-up menu and choose Currency. Do any of the following: Set the number of decimal places: In the Decimals field, type the number of decimal places you want to display. Numbers rounds the display value instead of truncating the display value.
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");
decimal money = 1000;
Response.Write(string.Format("{0:C}", money));
The above is an example in C#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With