How to Get the dates of a certain day of the week between two dates. Example: All the dates of the Monday days between the range of 2016-01-19 to 2016-02-19 Reputed: 2016-01-23 2016-01-30 2016-02-06 2016-02-13
This is what I am doing but I am getting on Wednesdays:
DECLARE @TEMP TABLE(REGISTRO DATE)
DECLARE @startdate datetime = '2016-01-19'
DECLARE @enddate datetime = '2016-02-19' ;with cte(col)
AS
(
SELECT @startdate
UNION ALL
SELECT col + 1
FROM cte
WHERE col <= @enddate
)
INSERT INTO @TEMP
SELECT *
FROM cte
WHERE DATEDIFF(dd,0,col)% 7 = 0
SELECT * FROM @TEMP