How to Round a Time in T-SQL

前端 未结 2 461
小鲜肉
小鲜肉 2020-11-27 16:42

I\'me looking for a function that would receive a time and would round it to the next/previous hour / half-hour / quarter / minute.

2条回答
  •  春和景丽
    2020-11-27 17:28

    Very nice thanks. I used it in-line to round to 15 minutes

    convert(smalldatetime,ROUND(cast(TDatalog.Time as float) * (24/.25),0)/(24/.25)) AS RoundedTime
    

提交回复
热议问题