Click to See Complete Forum and Search --> : datediff function in sql server returns only number of hours but not minute


mpoincare
May 14th, 2004, 09:17 AM
Hi everybody,
I am using the datediff function in sql server to return the number of hours and minute between 8:10AM and 4:35PM and the function return only the number of hour but not the number of minutes. Datediff(MI,'8:10 AM','4:35 PM')/60 returns 8 (hours), but no minutes.

hspc
May 15th, 2004, 04:03 AM
select cast(Datediff(MI,'8:10 AM','4:35 PM')/60 as varchar(10)) + ' hours'
,cast(60*(Datediff(MI,'8:10 AM','4:35 PM')/60.0 - Datediff(MI,'8:10 AM','4:35 PM')/60) as varchar(10)) + ' minutes'