Reputation: 817
I have this value in a field +000000019900000000
The actual value that I need is 19.90.
How do I write a statement to convert and cast this all on the same line?
Upvotes: 0
Views: 94
Reputation: 817
Here's another way to do this.
SELECT
'CLOSE PRICE' = CAST(round(CLOSEPRICE,2)as decimal (30,2))
FROM TABLE
This is what I ended up using in my query.
Upvotes: 0
Reputation: 797
SELECT
CAST(LEFT(CLOSE_PRICE,10)
+'.'
+RIGHT(CLOSE_PRICE,LEN(CLOSE_PRICE)-10) AS DECIMAL(10,2))
FROM [testTable]
It would be fine. I tested the result is 19.90
Upvotes: 1