August 14, 2013 at 3:13 pm
Hi,
I have a decimal field (10,4) that has values in it like:
0.0123
0.0063
0.0595
I need a way in my select statement to make them look like:
1.23
0.63
5.95
I've tried this but it's not correct:
SELECT
CAST([Overtime Actual Percentage].[Actual Overtime Percentage]*100 AS DECIMAL(20)) AS 'Actual Overtime Percentage',
August 14, 2013 at 3:20 pm
Just convert it to a decimal(10,2) instead of decimal(20) after you multiply by 100.
convert(decimal(10,2), mydec * 100)
August 14, 2013 at 3:32 pm
August 14, 2013 at 3:39 pm
Luis Cazares (8/14/2013)
Even better would be a decimal(8,2) 🙂
You'd get an error if you had a number that filled up that decimal(10,4) though, would you not?
123456.7890 * 100 would not fit into a decimal(8,2).
August 15, 2013 at 6:46 am
works fine...thanks!
August 15, 2013 at 7:55 am
roryp 96873 (8/14/2013)
Luis Cazares (8/14/2013)
Even better would be a decimal(8,2) 🙂You'd get an error if you had a number that filled up that decimal(10,4) though, would you not?
123456.7890 * 100 would not fit into a decimal(8,2).
And I got it completely wrong. In my head I only thought on truncating the last 2 decimals (I'm not sure why) :hehe:
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply