declare @StartDate DateTime = '2023-03-05',
@EndDate DateTime = '2023-03-26';
WITH CTE_date AS (
SELECT @StartDate as dt
UNION ALL
SELECT DATEADD(day,1,dt) as dt FROM CTE_date
WHERE dt<=@EndDate
)
SELECT count(dt) as 'List of sundays'
FROM CTE_date
WHERE DATENAME(weekday ,dt) IN ('Sunday');