Wednesday, April 6, 2011

how to get hours from subtracting two date time values in SQL Server 2005

I have two date values: 08/6/2009 00:00:00 and 10/6/2009 23:59:59.

How do I get the difference in hours in a query in SQL Server 2005?

From stackoverflow
  • SELECT  DATEDIFF(hour, '2009-08-06 00:00:00', '2009-10-06 23:59:59')
    
    ---
     71
    
  • DATEDIFF(HOUR,'08/6/2009 00:00:00','10/6/2009 23:59:59')

0 comments:

Post a Comment