I have following seed input data:
Thats just example how company payroll goes.
Now,
Would the following not work?
DECLARE @StartDate DATETIME
SELECT @StartDate = '2016-05-01 00:00:00.000'
DECLARE @EndDate DATETIME
SELECT @EndDate = '2017-04-01 00:00:00.000'
DECLARE @Dates TABLE(StartDate DATETIME, EndDate DATETIME)
WHILE @StartDate <= @EndDate
BEGIN
INSERT INTO @Dates (StartDate, EndDate)
SELECT @StartDate - 13, @StartDate WHERE DATEPART(WEEK, @StartDate) % 2 = 1 AND DATEPART(WEEKDAY, @StartDate) = 7
SET @StartDate = @StartDate + 1
END
-- Check the dates here... should be every 2 weeks
SELECT * FROM @Dates