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
 General SQL Server Forums
 New to SQL Server Programming
 Round values to two decimal places

Author  Topic 

FusionFashion
Starting Member

9 Posts

Posted - 2010-07-19 : 21:13:32
Dear Team,

Good Day!!

What will be the best function to use when you want the results to be rounded off to two decimal places?

For Example: My result is 46.72555, i want that the result will be 46.73.


Here is my code:

SELECT DATEDIFF(minute,dbo.tblAttendanceDetail.TimeIn, dbo.tblAttendanceDetail.TimeOut)/60.0
FROM tblAttendanceDetail


Color 'N Spice

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-19 : 21:27:32
round( < the number > , 2)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

FusionFashion
Starting Member

9 Posts

Posted - 2010-07-19 : 21:51:05
Thanks.. It's already fine now.

Color 'N Spice
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-20 : 03:38:17
or

select cast(46.72555 as decimal(12,2))


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -