SQL Server 中的 Money 数据类型仅获取两位小数
SELECT ROUND(123.4567, 2)` gives me `123.4600`
但我需要123.46
。
字段的数据类型是money。
解决方案:
<%# DataBinder.Eval(Container.DataItem, "FieldName","{0:0.00}") %>
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}") %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
会做你想做的事
Will do what you are after
如果适用,在视图层而不是数据层进行格式化,即读取所有数据并稍后截断(例如在 C# 客户端中)
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)
@IsmailS - 对我来说,更大的图景是让数据服务器尽可能格式化,特别是当它像内联转换一样简单时。它可以减少其他代码中的混乱。例如,转换价格,一个货币字段:
select CAST(Price as numeric(17,2)) Price from PriceTable
YMMV - It's my个人经历。
@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.
请参阅 http://msdn.microsoft.com/en-us /library/ms175003(SQL.90).aspx
See http://msdn.microsoft.com/en-us/library/ms175003(SQL.90).aspx
它会帮助你
It will Help You Out