SET DATEFIRST 1; DECLARE @from_date date DECLARE @to_date...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Mythology

Q&A for enthusiasts and scholars of mythology and folklore

SET DATEFIRST 1;
DECLARE @from_date date
DECLARE @to_date date;
DECLARE @noModificationYears nvarchar(max);
SET @from_date = '2020-01-01';
SET @to_date = '2020-12-31';
;with CTE As  
		(  
			SELECT DATEADD(day, 0, @from_date) AS the_date
			UNION ALL  
			SELECT DATEADD(day, 1, the_date) AS TheDate FROM CTE  
			WHERE the_date < @to_date

		)
		SELECT 
			@noModificationYears = (
				SELECT 
					CONVERT(NVARCHAR(6), DATEPART(year, the_date)) +','
				FROM CTE GROUP BY DATEPART(week, the_date), DATEPART(year, the_date) 
					HAVING COUNT(DATEPART(year, the_date)) = 7 AND DATEPART(week, the_date) = '1' 
					FOR XML PATH('')
			)
		OPTION (MAXRECURSION 0);
Select @noModificationYears;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results