I often enjoy seeing interview questions where the contestant has to write SQL Scripts. Here is another such example.
Question: How to find weekdays between two dates?
Answer: Here is a function which can be used to find weekdays between two dates.
CREATE FUNCTION dbo.getDayCount(@startdate date, @enddate date)
DECLARE @count INT = 0
IF DATEPART(dw,@startdate) > 1 AND DATEPART(dw,@startdate) < 7
SET @count = @count + 1
SET @startdate = DATEADD(DAY,1,@startdate)
-- Execute Function
SELECT dbo.getDayCount ('10/10/2015', '11/10/2015')
Reference: Pinal Dave (https://blog.sqlauthority.com)