Link to home
Start Free TrialLog in
Avatar of engineroom
engineroom

asked on

MS Sql Server - Rounding a number UP or Down

Hey all, if i have a number,...

5.370023489080

How do i get it to round down?  or maybe even cutting off the .370023489080

Thanx all
Avatar of mastoo
mastoo
Flag of United States of America image

Round( number, length)

or use Floor or Ceiling functions to go up or down.
Avatar of chapmandew
2 decimal points


select cast(5.370023489080 as decimal(18,2))

0 decimal points


select cast(5.370023489080 as decimal(18,0))
Avatar of digital_thoughts
digital_thoughts

Cast the number as an INT:

DECLARE @Test REAL
SET @Test = 5.370023489080
SELECT @Test
SELECT CAST(@Test AS INT)
ASKER CERTIFIED SOLUTION
Avatar of P_Ramprathap
P_Ramprathap
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The first answer on this thread that suggested floor and ceiling wasn't detailed enough?
Avatar of engineroom

ASKER

Sorry mastoo. As I really don't know the functions of SQL, the example provided by p_ramprathap really gave me a solid understanding of what i needed to do.