SQL query - inclue only work days
Posted on 2006-10-26
I have to create a query that determines the difference in time between two dates and then calculate the average time difference based on a grouping of another field. There is a trick however - the calculation of the difference in time should exclude Saturdays and Sundays. The query as follows:
SELECT t.name, AVG(DATEDIFF(dd,t.dateone,t.datetwo) AS time
FROM db.dbo.table t
GROUP BY t.name
I have no idea how to do the exclusion of Saturdays and Sundays in the calculation. Any help would be much appreciated.