Converting Seconds into Hours

  • I'm developing Telephony interaction Reports by reporting on our agents and their times on the phone, however, data shows time as seconds, so for example:

    agent 1 shows total interaction time of 15794 seconds for a specific week. I just happen to know that in Hours it would be 4 hours 23 minutes 14 seconds (4:23:14). My problem is trying to convert or use a function that will return the result in parenthesis.

    Can anyone assist in providing a syntax or function that I may be able to save.

    thx,

    John

  • You could turn it into a datetime value, and then format the output correctly. That would handle your display/conversion issue.

    It would look something like:

    select convert(char,dateadd(second,15794,0),108)

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Alternately:

    select

    right('0' + cast(floor(InteractionTime/3600) as varchar(2)), 2) + ':' +

    right('0' + cast(floor((InteractionTime%3600)/60) as varchar(2)), 2) + ':' +

    right('0' + cast(InteractionTime%60 as varchar(2)), 2)

    (Assuming the column is "InteractionTime".)

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply