Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the number of hours between the two dates in sql

Tags:

sql

sql-server

How to get the number of hours between the two dates in SQL Server

Example:

staffing_start_date (2017-08-01 06:00:00.00000)
staffing_end_dt (2017-08-01 18:00:00.00000)
like image 805
Tburg Avatar asked Jan 25 '26 22:01

Tburg


1 Answers

You would use datediff():

select datediff(hour, staffing_start_date, staffing_end_date)
like image 154
Gordon Linoff Avatar answered Jan 28 '26 13:01

Gordon Linoff