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 2005 Forums
 Transact-SQL (2005)
 Round and show to 2 decimal places?

Author  Topic 

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2008-05-16 : 08:39:36
Hi All,

I have a small question to ask. How to round a numeric field upto 2 decimal places, and also show it with 2 decimal places only

For example the following would return 255.88000000000
select round(255.87908765444,2)

How to get 255.88 only?

Pleas help.

Thanks,

Zee

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-16 : 08:49:26
hi
try this
select convert(decimal(5,2),round(255.87908765444,2))


ok
tanx...
Go to Top of Page

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2008-05-16 : 10:54:37
Thanks soorajtnpki....
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-05-16 : 11:17:28
You want to round up to 2 decimal places? The function there will round 255.87408765444 down (to 255.87)...

Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page
   

- Advertisement -