ms sql server time duration in decimal

we have sql server table with a decimal time duration column (in milliseconds) for each detail record. The column name is "duration". Example of the records values:
rec 1       468
rec 2     2375
rec 3     1172

if we need to know the total time duration for the 3 records can we just sum the 3 records and then covert to time format.
i was using:   sum(cast (duration as bigint) as TotDuration
ShenAsked:
Who is Participating?
 
Scott PletcherSenior DBACommented:
Yes, you can.

But the DATEADD/DATEDIFF functions only support integer, not bigint, so if those are involved, you would need to add net minutes and milliseconds separately to get a result date/time.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
SELECT CONVERT(TIME,DATEADD (ms, SUM(ColumnName), 0)) 
FROM YourTable

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.