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.