如何在SQL Server 2005中减去两个日期时间值

时间:2009-08-06 11:21:09

标签: sql sql-server-2005

我有两个日期值:08/6/2009 00:00:0010/6/2009 23:59:59

如何在SQL Server 2005中查询查询的小时数?

2 个答案:

答案 0 :(得分:10)

SELECT  DATEDIFF(hour, '2009-08-06 00:00:00', '2009-10-06 23:59:59')

---
 71

答案 1 :(得分:1)

DATEDIFF(HOUR,'08/6/2009 00:00:00','10/6/2009 23:59:59')