DATEDIFF(hour, start_date, end_date) will give you the number of hour boundaries crossed between
If you need the number of fractional hours, you can use
DATEDIFF at a higher resolution and divide the result:
DATEDIFF(second, start_date, end_date) / 3600.0
The documentation for
DATEDIFF is available on MSDN:
- Sql Server string to date conversion
- What is the significance of 1/1/1753 in SQL Server?
- How to get Time from DateTime format in SQL?
- SQL – The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
- Date conversion and culture: Difference between DATE and DATETIME
- SQL Server: Examples of PIVOTing String data
- Will ANSI JOIN vs. non-ANSI JOIN queries perform differently?
- Find a value anywhere in a database
- How can foreign key constraints be temporarily disabled using T-SQL?
- Check if table exists in SQL Server
- How to check if a column exists in a SQL Server table
- SQL query to select dates between two dates
- When should I use semicolons in SQL Server?
- Parameter Sniffing (or Spoofing) in SQL Server
- How to convert SQL Server’s timestamp column to datetime format
- How can I select the first day of a month in SQL?
- Get first day of week in SQL Server
- How can I escape square brackets in a LIKE clause?
- Fuzzy matching using T-SQL
- Combine multiple results in a subquery into a single comma-separated value
- SQL Server String or binary data would be truncated
- Datatype for storing ip address in SQL Server
- How do you view ALL text from an ntext or nvarchar(max) in SSMS?
- Floor a date in SQL server
- best way to convert and validate a date string
- How do I format a number with commas in T-SQL?
- Hidden Features of SQL Server
- Possible to store value of one select column and use it for the next one?
- How do I exclude Weekend days in a SQL Server query?
- How to compare datetime with only date in SQL Server
- Scheduled run of stored procedure on SQL server
- Find index of last occurrence of a sub-string using T-SQL
- Getting Dates between a range of dates
- T-SQL Dynamic SQL and Temp Tables
- SQL Server 2008 – How do i return a User-Defined Table Type from a Table-Valued Function?
- Best way to store time (hh:mm) in a database
- Find non-ASCII characters in varchar columns using SQL Server
- SQL Server Query – groupwise multiplication
- How to reuse calculated columns avoiding duplicating the sql statement
- Aggregate bitwise-OR in a subquery
- How do you determine what SQL Tables have an identity column programmatically
- PRINT statement in T-SQL
- SQL Server Group by Count of DateTime Per Hour?
- T-sql – determine if value is integer
- LPAD in SQL Server 2008
- how to get the start and end dates of all weeks between two dates in SQL server?
- SELECT INTO a table variable in T-SQL
- How do I move a table into a schema in T-SQL
- Generate MD5 hash string with T-SQL
- SQL Server: convert ((int)year,(int)month,(int)day) to Datetime [duplicate]