开发者

Convert a string field with pennies into a dollar amount with 2 decimal places in SQL Server

开发者 https://www.devze.com 2023-01-11 00:55 出处:网络
I have a field in a table as nvarchar(10), which is used to store a value in pennies. For example, $23.50 is stored as开发者_JS百科 \"2350\".

I have a field in a table as nvarchar(10), which is used to store a value in pennies. For example, $23.50 is stored as开发者_JS百科 "2350".

I need to return this value to the program in Money format. How would I do that in the Select statement?


SELECT CAST (IntAmount / 100.00 as MONEY)


 cast(cast (pennies as numeric(16,2))/100 as money)


Select convert(money, field/100, 0) from table
0

精彩评论

暂无评论...
验证码 换一张
取 消