Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

Time difference in hh:mm:ss

Select CAST((@EndDateTime-@StartDateTime) as time(0)) '[hh:mm:ss]'

--- OR ---

declare @StartDate datetime, @EndDate datetime
select @StartDate = '10/01/2012 08:40:18.000',@EndDate='10/04/2012 09:52:48.000'
select convert(varchar(5),DateDiff(s, @startDate, @EndDate)/3600)+':'+convert(varchar(5),DateDiff(s, @startDate, @EndDate)%3600/60)+':'+convert(varchar(5),(DateDiff(s, @startDate, @EndDate)%60)) as [hh:mm:ss]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Time #difference
ADD COMMENT
Topic
Name
6+6 =