PrimeDigit – A Design Blog by Will Shaver

December 18, 2008

Round datetime to nearest 5 minutes

Filed under: Uncategorized — Will @ 12:01 pm

This took me forever to find online, so I’m posting it here for the next helpless soul. If you need to round datetimes coming out of sql to the nearest 5 minutes, here you go.

dateadd(mi,(datepart(mi,dateadd(mi,1,DateTimeColumn))/5)*5,dateadd(hh,datediff(hh,0,dateadd(mi,1, DateTimeColumn)),0))

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress