You don't need to use a cursor. In fact DON'T use a cursor. Here is a way to do the same calculations without using cursors. I have created a test table and script that you can copy to an SSMS window and run to see how it works. I am displaying the results in minutes - it could be formatted to days/hours/minutes if required:create table #tmp (sln int, id int, startdate datetime, enddate datetime);insert into #tmp values (1,1,'20120101 10:12:00.000','20120101 10:13:00.000'),(1,1,'20120101 10:14:00.000','20120101 10:15:00.000'),(1,1,'20120101 10:15:00.000','20120101 10:16:00.000');with cte as( select a.*, row_number() over (partition by SLN order by startdate) as RN, datediff(mi,a.startdate,a.endDate) as Duration from #tmp a)select a.*, b.TimeElapsedfrom cte a outer apply ( select datediff(mi,b.StartDate,a.endDate) as TimeElapsed from cte b where b.SLN = a.SLN and b.RN = 1 ) bdrop table #tmp