I\'m trying to get the most recent Friday in SQL Server 2008.
I have this. It gets the beginning of the week (monday) then subtracts 3 days to get Friday.
The other solutions were not working for my use case.
This works for finding any previous day by replacing 'Sunday' with the day you`re looking for:
DECLARE @myDate DATE = GETDATE() WHILE DATENAME(WEEKDAY, @myDate) <> 'Sunday' BEGIN SET @myDate = DATEADD(DAY, -1, @myDate) END