sql server - How to split minutes into days, hours and minutes in tsql -
i have column consist of minutes. there simple way split minutes column 1 column shows days, hours, minutes only?
duration ----------- 67 ==> 1 hour, 7 minutes 1507 ==> 1 day, 1 hour, 7 minutes 23 ==> 23 minutes
i googled solution didn't find solution similar me. want show in report trying find how can solve column looks meaningfully. duration column's calculation this.
avg(datediff(minute, ei.sentdate, eo.sentdate)) over(partition ei.mailbox) duration
a google search landed me here http://www.sqlservercentral.com/forums/topic490411-8-1.aspx
and says... tested working ...
declare @theminutes int set @theminutes = 67 select @theminutes / 1440 nodays -- 1440 minutes per day , (@theminutes % 1440) / 60 nohours -- modulo 1440 , (@theminutes % 60) nominutes -- modulo 60
Comments
Post a Comment