Q:

How to display Hours and Minutes between two dates

I am having a table consists of to datetime columns "StartTime" and "CompleteTime". Initially completeTime column will be NULL untill the process is completed. And now my requirement is to display hours and minutes as shown Below
Output:
Ex: 2:01 Hr 
(This Means "2" represents hours and "01" represents minutes)
I Tried as below:
Declare @StartDate dateTime = '2016-03-31 04:59:11.253'
Declare @EndDate dateTime = GETUTCDATE()

SELECT REPLACE(CONVERT(VARCHAR,CAST(DATEDIFF(second, @StartDate, 
ISNULL(GETUTCDATE(),@EndDate)) / 36000.0 AS DECIMAL(9,2))) + ' hr','.',':')

Output:
0:05 hr

Required Output:
0:32 hr

Note: Hi while giving negative marking check my query once. I already referred some link's related to this but it won't work.

A:

Try this
DECLARE @STARTDATE DATETIME = '2016-03-31 04:59:11.253'
DECLARE @ENDDATE DATETIME = GETUTCDATE()

SELECT CONVERT(VARCHAR(10),DATEDIFF(MINUTE, @STARTDATE, @ENDDATE)/60)+':'+CONVERT(VARCHAR(10),DATEDIFF(MINUTE, @STARTDATE, @ENDDATE)%60)+' hr' AS DIFF

Result:
Diff
0:52 hr

Diff more than 24 hour also will handle this
72:56 hr

