Business Hours

Business Hours

I'm trying to write a MSSQL query that looks at different time intervals during a ticket's life.  For example, if I'm looking at a ticket that has a createdtime of '2019-11-20 09:52:11.000', missed SLA at '2019-11-22 14:53:54.000', but was only assigned to the proper personnel at '2019-11-30 13:50:09.000'.  Essentially, I want to calculate the time it spent in the service desk queue waiting to be assigned to the proper department.  Normally, I would just write a query like: select DATEDIFF(hh, '2019-11-20 09:52:11.000', '2019-11-30 13:50:09.000'), but that's a straight up difference in time.  I need something that will not include times outside of business hours and not factor in weekends. 

                  New to ADSelfService Plus?