I have the following table of TIME datatypes
clarification: I am representing hours/mins/seconds of videos and want to figure out how long the videos will be.
runtime
----------------
01:27:19.0000000
01:26:09.0000000
01:00:56.0000000
01:09:59.0000000
01:25:43.0000000
01:16:01.0000000
01:27:12.0000000
01:22:00.0000000
01:17:47.0000000
01:31:07.0000000
01:36:23.0000000
01:13:29.0000000
01:20:12.0000000
01:03:24.0000000
00:58:42.0000000
I want to get the SUM of all of these times.
I haven't used 2008 much yet and I don't have an instance handy where I am to check this, but something like this might work:
SELECT
DATEADD(ms, SUM(DATEDIFF(ms, '00:00:00.000', my_time)), '00:00:00.000')
FROM
dbo.My_Table
As le dorfier points out, adding times is a bit meaningless, because they are supposed to represent a time of day. I'm going under the assumption that you are using them to indicate hours/minutes/seconds.
Oh, and I have no idea what will happen with the above if it goes over 24 hours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With