Reputation: 9
How to get the difference in hours between two datetime ?
CASE WHEN CONVERT(varchar (5),a.[Entry_Date],108) <=(a.[Answer_Date]) THEN LEFT(CONVERT(varchar,a.[Answer_Date]-a.[Entry_Date],8),5)
ELSE ' ' END AS ExecutionTime
Upvotes: 0
Views: 41
Reputation: 1
use DATEDIFF() Function, like
select DATEDIFF(hour,'2019-07-23 10:10:10',getdate())
Upvotes: 0
Reputation: 2544
You must use DATEDIFF() function within a derived column:
Syntax
DATEDIFF(datepart, startdate, endate)
Example
DATEDIFF("Hour", [Entry_Date], [Answer_Date])
Upvotes: 1