Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the easiest way to always round a number down in SQL Server 2005?

I can't seem to find this anywhere, but what is the correct way to always round a number down, to a specific decimal precision, using SQL Server 2005?

Will I need to write my own function or is there already a function that does this?

I do know that SQL Server 2008 R2 has a ROUNDDOWN function, and it does exactly what I need. Does a similar function exist in 2005?

like image 900
RLH Avatar asked Dec 21 '22 02:12

RLH


2 Answers

Rounding down to a specific decimal place is the same as truncating to a decimal place... and you can use round() to do this:

select round(123.456789, 4, 1)

Returns:

123.456700
like image 192
Michael Fredrickson Avatar answered May 10 '23 23:05

Michael Fredrickson


Try FLOOR. Google "sql server 2005 floor"

http://msdn.microsoft.com/en-us/library/ms178531(v=sql.90).aspx

like image 32
David Wilkins Avatar answered May 10 '23 22:05

David Wilkins