0

I have set the dates in the parameter as below, but I'm lost with the next bit... what I want is;

If @TodayDayOfWeek < 5 (so it is Monday - Thursday) then run last week's dates (from @Startoflastweek - @endoflastweek) else use this weeks date range

DECLARE @TodayDayOfWeek INT

DECLARE @EndOfThisWeek datetime

DECLARE @StartOfThisWeek datetime

DECLARE @EndOfPrevWeek DateTime

DECLARE @StartOfPrevWeek DateTime

SET @TodayDayOfWeek = datepart(dw, GetDate())

set @EndOfThisWeek =  DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 4)

set @StartOfThisWeek =  DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0)

SET @EndOfPrevWeek = DATEADD(dd, -@TodayDayOfWeek, GetDate())

SET @StartOfPrevWeek = DATEADD(dd, -(@TodayDayOfWeek+6), GetDate())
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156

1 Answers1

0

Assuming you are using SQL Server and this is SProc

CASE WHEN @TodayDayOfWeek < 5 THEN
BEGIN
  -- YOUR LOGIC
END
ELSE
BEGIN 
  -- ELSE LOGIC
END
Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265