眼眸繁星
declare @StartDate datetime, @EndDate datetimeselect @StartDate = '10/01/2012 08:40:18.000',@EndDate='10/04/2012 09:52:48.000'select convert(varchar(5),DateDiff(s, @startDate, @EndDate)/3600)+':'+convert(varchar(5),DateDiff(s, @startDate, @EndDate)%3600/60)+':'+convert(varchar(5),(DateDiff(s, @startDate, @EndDate)%60)) as [hh:mm:ss]该查询将对您有所帮助。
九州编程
虽然可能不是最有效的,但这可以工作:declare @StartDate datetime, @EndDate datetimeselect @StartDate = '10/01/2012 08:40:18.000',@EndDate='10/04/2012 09:52:48.000'select convert(varchar(5),DateDiff(s, @startDate, @EndDate)/3600)+':'+convert(varchar(5),DateDiff(s, @startDate, @EndDate)%3600/60)+':'+convert(varchar(5),(DateDiff(s, @startDate, @EndDate)%60))如果您可以运行两个选择,那会更好,因为您只执行一次datediff:declare @StartDate datetime, @EndDate datetimeselect @StartDate = '10/01/2012 08:40:18.000',@EndDate='10/04/2012 09:52:48.000'declare @Sec BIGINTselect @Sec = DateDiff(s, @startDate, @EndDate)select convert(varchar(5),@sec/3600)+':'+convert(varchar(5),@sec%3600/60)+':'+convert(varchar(5),(@sec%60))