Morning,
I know I am close BUT I still can't get this code snippette to return the date of last sunday (as in 1/9/2011 - format of date does not matter).
Here is what I have so far (borrowed from a web page):
Thanks!
Thanks
J. Kusch
I know I am close BUT I still can't get this code snippette to return the date of last sunday (as in 1/9/2011 - format of date does not matter).
Here is what I have so far (borrowed from a web page):
Code:
DECLARE @LastSundayNight DateTime
SET @LastSundayNight = GetDate()
SELECT CASE WHEN DATENAME(dw,@LastFridayNight) ='Sunday' AND CONVERT(VarChar,@LastSundayNight,108) > '22:00:00'
THEN CONVERT(VarChar,@LastSundayNight,1)
ELSE CONVERT(VarChar,DATEADD(d,-((datepart(dw,@LastSundayNight)+@@DATEFIRST)%7+1),@LastSundayNight),1)
END + ' 22:00:00'
Thanks!
Thanks
J. Kusch