This query will help you to find out difference between two dates in Hours, Minutes, Seconds in SQL Server.
DECLARE @First datetime
DECLARE @Second datetime
SET @First = '04/17/2008 08:00:00'
SET @Second = getdate()
SELECT DATEDIFF(hour,@First,@Second) as TotalHours,
DATEDIFF(minute,@First,@Second) - (DATEDIFF(hour,@First,@Second) * 60) as TotalMinutes,
DATEDIFF(second,@First,@Second) - (DATEDIFF(minute,@First,@Second) * 60) as TotalSeconds
No comments:
Post a Comment