Had a requirement to calculate the weekdays between given date range (No of Days – Weekends). Finally with the help of WWW, I manage to figure out a way to do it in MS SQL
DECLARE @START_DATE = '2012-09-17' DECLARE @WEEKDAYS INT SELECT @WEEKDAYS = ( (DATEDIFF(dd, @START_DATE, GETDATE()) + 1) -(DATEDIFF(wk, @START_DATE, GETDATE()) * 2) -(CASE WHEN DATENAME(dw, @START_DATE) = 'Sunday' THEN 1 ELSE 0 END) -(CASE WHEN DATENAME(dw, GETDATE()) = 'Saturday' THEN 1 ELSE 0 END))
Subscribe to our mailing list
Subscribe to our mailing list and receive a free udpates
Thank you for subscribing.
Something went wrong.