Camillia
asked on
Multiply and round down
There's a VB6 code here and I took the logic and converted it to a stored proc.
VB code value is 5626 so it rounds down. The stored proc I have shows 5627. So, in below code, how can I round down?
This is SQL 2014
VB code value is 5626 so it rounds down. The stored proc I have shows 5627. So, in below code, how can I round down?
This is SQL 2014
declare @settledtest decimal(5,5)
declare @settledWeight int
set @settledtest = 0.41250
set @settledWeight = 13640
select @settledTest * @settledWeight ---gets 5626.50000
select Round(@settledTest * @settledWeight,0) -- gets 5627.00000. *** This is what I have in the stored proc. How can I round down?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
why round after using Floor?
it's ok to do so, but it's an extra function call without adding value.
it's not the same thing as casting to Int though, because the cast will actually change the result type. That may or may not be ok, but it is functionally different.
it's ok to do so, but it's an extra function call without adding value.
it's not the same thing as casting to Int though, because the cast will actually change the result type. That may or may not be ok, but it is functionally different.
ASKER
Thanks, let me run some more values
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll check the VB code again. I think what I have might not be correct. I just ran some more tests and I don't think I can just round down.
I'll post back tomorrow (or close this and reopen a new one)
I'll post back tomorrow (or close this and reopen a new one)
ASKER
I'll run more tests in the morning.
ASKER
Open in new window
Different than casting as int?