In the following calculation I am receiving my output as 000000.9000. I need it to look like 00000000.90. I cant seem to loose the 2 zeros at the end. Can anyone help me with this? Keep in mind that my output has to be varchar.
right('00000000000' + cast((st.rate_dlr * .01) * 10 as varchar),11)If you only need positive values, you can use:SELECT Replace(Str(st.rate_dlr * 0.01, 11, 2), ' ', '0')Allowing negative numbers gets a bit more complicated, but until you decide how you want them formatted I could only guess anyway.
-PatP|||Thanks for your reply...I finally figured it out. Here is basically what I did.........
select Cost_cast = right('000000.00' + convert(varchar,convert(decimal(6,2),round(4444.22 22,2))),9)|||Before you get too frisky, I'd checkselect Cost_cast = right('000000.00'
+ convert(varchar,convert(decimal(6,2)
, round(44.2222,2))),9)I think you might prefer my solution!
-PatP
No comments:
Post a Comment