Program to find the difference in hours from the given date and time and Current Date and Time

Rajnilari2015
Posted by Rajnilari2015 under Sql Server category on | Points: 40 | Views : 447
DECLARE @T TABLE(Dt datetime)
INSERT INTO @T VALUES
('2016-01-31 14:47:20.650'),('2016-01-30 14:47:20.650'),
('2016-01-29 14:47:20.650'),('2016-01-28 14:47:20.650'),
('2016-01-27 14:47:20.650'),('2016-01-26 14:47:20.650')

SELECT
Dt,
CurrentDT = GETDATE(),
DATEDIFF(HH ,Dt, GETDATE()) HrsDiff
FROM @T

Comments or Responses

Login to post response