SQL to return the number of working days between 2 passed in dates
问题 I need to write an sql query that returns the number of Working days (Monday - Friday) between two given dates. I was wondering what would be the most efficient way to do this? SELECT --Start with total number of days including weekends (DATEDIFF(dd,@StartDate,@EndDate)+1) --Subtact 2 days for each full weekend (DATEDIFF(wk,@StartDate,@EndDate)*2) --If StartDate is a Sunday, Subtract 1 ELSE 0 END) --If EndDate is a Saturday, Subtract 1 FROM dual Then it would also be helpful to be able to