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 seconds.

Author  Topic 

hspatil31
Posting Yak Master

182 Posts

Posted - 2011-12-23 : 08:26:51
Dear All,

I am using following select statement in my SP. I want to complete this 54 seconds in minute. Means output should shows 60.

And If my duration is 96 then output should shows 120.
Can anybody please tell me how to resolve this issue ?

@duration = 54(In Second)
SELECT @Duration_RoundedTo6 = (CASE WHEN (@duration%6) =0 THEN ROUND((@duration/6),0) ELSE ROUND((@duration /6 ) + 0.5 ,0) END ) * 6

Output: 54

Thanks and Regard's
Harish Patil

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-12-23 : 08:41:37
Did you mean rounding to the nearest 60. Would this work?
(@duration+30)/60*60
Go to Top of Page

hspatil31
Posting Yak Master

182 Posts

Posted - 2011-12-23 : 10:59:24
Hello Friend,

Thnks I resolved my issue.

Thanks and Regard's
Harish Patil
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-12-23 : 11:02:19
1 tequila, 2 tequila, 3 tequila, FLOOR()



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -