Reputation: 10863
SELECT ROUND(123.4567, 2)` gives me `123.4600`
But I need 123.46
.
Data type of field is money.
Solution:
<%# DataBinder.Eval(Container.DataItem, "FieldName","{0:0.00}") %>
Upvotes: 10
Views: 66001
Reputation: 61
@IsmailS - To me, the larger picture is to let the data server format as much as possible, especially when it's something as simple as an inline cast. It yields less clutter in your other code. For example, casting Price, a money field:
select CAST(Price as numeric(17,2)) Price from PriceTable
YMMV - It's my personal experience.
Upvotes: 4
Reputation: 100278
If applicable, format on the view layer, not on the data layer, i.e. read all the data and truncate it later (such as in C# client)
Upvotes: 13
Reputation: 29
SELECT ROUND(123.4567, 2,1)
See http://msdn.microsoft.com/en-us/library/ms175003(SQL.90).aspx
Upvotes: 2
Reputation: 48547
SELECT CAST(ROUND(123.4567, 2) AS MONEY)
Will do what you are after
Upvotes: 26