Convert decimal number to INT SQL

85,838

Solution 1

Or you can replace the decimal point.

select cast(replace('3562.45', '.','') as integer)

This way, it doesn't matter how many decimal places you have.

Solution 2

How about the obvious:

CAST(3562.45*100 as INTEGER)

Solution 3

This works for me

SELECT FLOOR(55.5999)

Solution 4

You can use also the CONVERT function:

SELECT CONVERT(INT, 3562.45 * 100)
Share:
85,838
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I want to convert the decimal number 3562.45 to 356245, either as an int or a varchar. I am using cast(3562.45 as int), but it only returns 3562. How do I do it?