Q&A for professional and enthusiast programmers
create table #datetmp ( datea datetime not null, dateb datetime not null); insert into #datetmp values ('2015-01-01 00:30', '2015-01-01 01:30'); insert into #datetmp values ('2015-01-01 00:05', '2015-01-01 00:15'); insert into #datetmp values ('2015-01-01 00:55', '2015-01-01 01:05'); insert into #datetmp values ('2015-01-01 00:59', '2015-01-01 12:01'); select datea, dateb, datediff(hour, datea, dateb) as Hours, datediff(minute, datea, dateb) as Minutes from #datetmp