Reputation: 471
I have passed below AmountDue in query but am getting wrong result. AmountDue data type is Float.
AmountDue: 2412880.28
AmountDue: 561.06
My query:
select CONVERT(varchar,(select convert(bigint,AmountDue*100)))
from dbo.tblBidResults
I am getting below results which is wrong:
241288027
56105
Correct Result:
241288028
56106
Upvotes: 4
Views: 496
Reputation: 11609
DECLARE @temp float
set @temp = 2412880.28
select convert(varchar,convert(decimal(9,0),@temp*100))
Upvotes: 1
Reputation: 85126
try converting to numeric instead of bigint:
DECLARE @temp float
set @temp = 2412880.28
SELECT CONVERT(varchar,(CONVERT(numeric(27,0),@temp*100)))
There is a good post that goes over the reason for this here.
Upvotes: 1