sql server - Cannot get hours to total over 24, eg 48 hours in hh:mm:ss output -
i running query find out total amount of time user has been browsing for. each browsing session stored in db seconds , sum total seconds , convert hh:mm:ss.
problem when i'm converting seconds hh:mm:ss
. want display example '78:20:00'
dont know how code total this. when gets past 24 hrs hrs column goes 00 because day.
the query run convert time can seen below:
select username, convert(varchar(12),dateadd(second,totaltimeinseconds,0),108) totalhours #totalsessiontime
select username, cast(totaltimeinseconds / (60 * 60) varchar) + ':' + cast(totaltimeinseconds % (60 * 60) / 60 varchar) + ':' + cast(totaltimeinseconds % (60) varchar) totalhours #totalsessiontime
if want minutes , seconds 2 digits, you'll have left pad them, make ugly example, work fine.
Comments
Post a Comment