Using SQL Server 2008, I need to sum the business minutes between two datetime fields, while taking into consideration non working hours and weekends/company holidays. I would like to incorporate a calendar if possible so that should I need to edit any holiday it could be easily done.

E.g.

```
OpenCall              CloseCall 
05/08/2013 14:00:00   06/08/2013 09:30:00             

```

The result for the above, needs to return: 240 -- (4 hours) working hours are: 08:30-17:00.

If the call was open on Friday and was closed on Tuesday, then it should only calculate the minutes between the working hours on Friday, Monday and Tuesday (i.e not the weekend).

I'm new to SQL/T-SQL so please explain any code/variables clearly - IF you can find a neat solution!

Thanks in advance!