I have a procedure that return start date and end date as follows:
create procedure [GetWeekdays]( @Date Date ) As
As Declare @Fri datetime, @Mon datetime
set @Fri=(SELECT DATEADD(d, 6- DATEPART(dw, @Date), @Date)) set @Mon= (SELECT DATEADD(wk, DATEDIFF(wk,0,@Date), 0) MondayOfCurrentWeek)
DECLARE @StartDate DATE = @Mon, @EndDate DATE = @Fri
SELECT date FROM ( SELECT DATE = DATEADD(DAY, rn - 1, @StartDate) FROM ( SELECT TOP (DATEDIFF(DAY, @StartDate, DATEADD(DAY,1,@EndDate))) rn = ROW_NUMBER() OVER (ORDER BY s1.[object_id]) FROM sys.all_objects AS s1 CROSS JOIN sys.all_objects AS s2 ORDER BY s1.[object_id] ) AS x ) AS y
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.