I tried with
select ROUND(1235.53)
--(It can contain "n" digit of scale)
But I got this error:
The round function requires 2 to 3 arguments.
I am not sure what is the use of other parameters.
Convert Float to Int In this example, we will convert a float data type to integer. In the following query, we will declare a variable that data type is float and then we will use the SQL CONVERT function in order to convert float value to integer so for that we will perform data converting operation.
SQL Server ROUND() Function The ROUND() function rounds a number to a specified number of decimal places. Tip: Also look at the FLOOR() and CEILING() functions.
A float value can be converted to an int value no larger than the input by using the math. floor() function, whereas it can also be converted to an int value which is the smallest integer greater than the input using math. ceil() function.
Better to use CAST INT/CEILING/FLOOR:
SELECT CEILING(1235.53)
SELECT FLOOR(1235.53)
SELECT CAST(1235.53 AS INT)
CEILING: Gives you the upper bound integer value
FLOOR: Gives you the lower bound integer value
Set decimals to zero
select cast(ROUND(1235.53,0) as int) Returns 1236
select cast(1235.53 as int) Returns 1235
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With