try this.. :)
declare @fromDate datetime,@toDate datetime
set @fromDate='12 Jun 2014'
set @toDate='28 Jun 2014'
;WITH CTEQuery AS (
SELECT CAST(@fromDate AS DATETIME) AS FirstDay, DATEADD(dd, 7, @fromDate) as LastDay
UNION ALL
SELECT DATEADD(dd, 7, FirstDay), DATEADD(dd, 7, LastDay)
FROM CTEQuery s
WHERE DATEADD(dd, 7, FirstDay) <= CAST(@toDate AS DATETIME)
)
select * from CTEQuery
you can pass
@fromDate
and
@toDate
dynamically here i have passed it for example.. :)