Get Workday count with out weekends

This has come up before in my line of work, to get a total workday count but with out the weekends.

(DATEDIFF(dd, StartDate, EndDate) + 1)
-(DATEDIFF(wk, StartDate, EndDate) * 2)
-(CASE WHEN DATENAME(dw, StartDate) = 'Sunday' THEN 1 ELSE 0 END)
-(CASE WHEN DATENAME(dw, EndDate) = 'Saturday' THEN 1 ELSE 0 END) AS TotalWorkDays

Comments

Popular posts from this blog

Service Broker and External Activator for Sql Server...

Lighting Quick Table RowCounts for your Tables

List to Table