• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2052
  • Last Modified:

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
0
engineroom
Asked:
engineroom
1 Solution
 
mastooCommented:
Round( number, length)

or use Floor or Ceiling functions to go up or down.
0
 
chapmandewCommented:
2 decimal points


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

0 decimal points


select cast(5.370023489080 as decimal(18,0))
0
 
digital_thoughtsCommented:
Cast the number as an INT:

DECLARE @Test REAL
SET @Test = 5.370023489080
SELECT @Test
SELECT CAST(@Test AS INT)
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
P_RamprathapCommented:
Try with floor and Ceiling

e.g for Floor

select floor(56783.78566) = 56783
select floor(56783.2345) = 56783

e.g for Ceiling
select ceiling(56783.2345) = 56784
select ceiling(56783.785665) = 56784
0
 
mastooCommented:
The first answer on this thread that suggested floor and ceiling wasn't detailed enough?
0
 
engineroomAuthor Commented:
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.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now