We help IT Professionals succeed at work.

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
Watch Question

Senior DBA
Most Valuable Expert 2018
Top Expert 2014
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.
Vitor MontalvãoIT Engineer
Distinguished Expert 2017
FROM YourTable

Open in new window