Have a look at this code:SET DATEFIRST 1DECLARE @dd DATETIMEIF DATEPART(WEEKDAY,GETDATE()) = 1BEGIN SET @dd = DATEADD(DAY,-3,DATEDIFF(DAY,0,GETDATE()))ENDELSEBEGIN SET @dd = DATEADD(DAY,-1,DATEDIFF(DAY,0,GETDATE()))ENDSELECT DATENAME(WEEKDAY,@dd),DATEPART(WEEKDAY,@dd),@dd
The first line the SET DATEFIRST 1 assigns a number to a day of the week, in this case, I have set Monday as 1, Tuesday as 2, Wednesday as 3 etc.Then the query looks at the weekday number, if it is 1, it uses the DATEADD function to pick a date 3 days ago, and if it is 2-7 it simply uses the previous day.The variable @dd, can then be used in your main query to select your data e.g. WHERE mydate = @dd---------------------------------------------------------------------------------http://www.mannyroadend.co.uk A Bury FC supporters website and forum