Adding time

  • Ok, sorry for the dumb question but I am stumped as the best way to add up a bunch of hh:mm::ss data. My data looks like this:

    User Start End Duration

    371 2011-12-02 21:36:18.000 2011-12-03 04:55:20.000 07:19:02

    371 2011-12-03 04:56:14.000 2011-12-03 08:40:19.000 03:44:05

    371 2011-12-03 21:31:32.000 2011-12-03 21:48:31.000 0:16:59

    371 2011-12-03 21:48:38.000 2011-12-04 02:44:46.000 04:56:08

    371 2011-12-04 02:52:43.000 2011-12-04 08:02:18.000 05:09:35

    371 2011-12-04 21:31:20.000 2011-12-05 07:35:59.000 10:04:39

    371 2011-12-08 13:30:38.000 2011-12-08 15:19:57.000 01:49:19

    371 2011-12-08 15:32:54.000 2011-12-08 16:32:53.000 0:59:59

    371 2011-12-08 16:40:16.000 2011-12-08 17:45:19.000 01:05:03

    371 2011-12-08 18:16:32.000 2011-12-08 21:40:59.000 03:24:27

    I need to sum up all of the duration to display total HH:MM:SS.

    Thanks

  • Multiply the hours duration by 3600, the minutes duration by 60. Total those up with the seconds, and you have a total seconds of duration. Even easier, skip that step and just use DateDiff(second) on the start and end times.

    Then just sum up the seconds. Divide by 3600 to get hours, divide the modulus of that by 60 to get minutes, and the mod of that is seconds.

    - 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 2 posts - 1 through 1 (of 1 total)

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