Skip to content
Advertisement

Calculate business hours between two dates

How can I calculate business hours between two dates? For example we have two dates; 01/01/2010 15:00 and 04/01/2010 12:00 And we have working hours 09:00 to 17:00 in weekdays How can I calculate working hours with sql?

Advertisement

Answer

Baran’s answer fixed and modified for SQL 2005

SQL 2008 and above:

SQL 2005 and below:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement