Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Round to next 5 value
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01201576
Message ID:
01201607
Views:
18
This message has been marked as a message which has helped to the initial question of the thread.
>I have a value that represents duration, some of them are like 29, 14, 59. In my case these represent minutes, I'm looking for a way within a stored procedure to "round" them to the nearest 5 minute value.
>
>so 29 would become 30
>.. 14 would become 15
>.. 59 would become 60
>
>Thanks for any help.
>
>Kirk

Re: Round to nearest 5 Thread #980330 Message #980345

Using google to search
declare @dt datetime 

select @dt = '2006-09-14 08:01:32.700' 

select @dt, 
rounded = dateadd(minute, datediff(minute, 0, @dt) / 5 * 5, 0)
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform