Monday, 23 February 2015

How To Check Time Difference in SQL Server

-- How To Check Time Difference in SQL Server

 DECLARE @StartTime DateTime = DateAdd(Mi, -15, GetDate())
 Select @StartTime  StartTime;
 Declare @EndTime DateTime = GetDate()
 Select @EndTime  EndTime

 -- Now See the Difference betwen StartTime and EndTime


Select Convert(Varchar(15), DateAdd(Ms, DateDiff(Ms, @StartTime, @EndTime),0),114) as TimeDifference




--WAITFOR DELAY '00:00:10'

No comments:

Post a Comment