How to get total number of hours between two dates in sql server?
You want the DATEDIFF function:
SELECT DATEDIFF(hh, @date1, @date2)
@codeka answered with the hours part (from your title) but in the body of your question you asked for hours and minutes so, here is one way
select DATEDIFF(hh, @date1, @date2) as Hours_Difference,
DATEDIFF(mi,DATEADD(hh,DATEDIFF(hh, @date1, @date2),@date1),@date2) as Minutes_Difference
What this does in the first part is what @codeka showed. It gives you the datediff between the two dates in actual full hours. The second term in the sql gives the datediff in minutes between the (first date + the hours elapsed) and the second date. You have to eliminate the hours from the equation in the minutes part or you will get the actual minutes between the dates. Datediff and its allowed Datepart identifiers can be researched here:
http://msdn.microsoft.com/en-us/library/ms189794.aspx
The problem with William Salzman's answer is that it returns strange answers if the first time is not on the hour. So 10:30 to 12:00 gives 2 hours and -30 minutes.
If that isn't what you want, then this will give you 1 hour and 30 minutes:
select
CONVERT(int,DATEDIFF(mi, @date1, @date2) / 60) as Hrs_Difference,
CONVERT(int,DATEDIFF(mi, @date1, @date2) % 60) as Mins_Difference