Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to limit the float to two decimal values

Author  Topic 

nayanancha
Starting Member

27 Posts

Posted - 2012-05-08 : 14:52:24
I am having a value like 22.1234231

I want to limit this value to two places after decimal, but donn want to round.

How could i do this?

I would like the output to be as 22.12

Thanks,

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-08 : 15:05:22
declare @f float
set @f = 22.1234231
select convert(decimal(4,2), @f)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-05-08 : 15:23:06
This will truncate everything after the 2nd decimal
select floor(@f*100)/100.0


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -