This follows on from a previous questionin which I was given some great answers but I now want to tweak the syntax slightly to schieve different things, hoping someone can help.
This is the earlier question: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_28182893.html
So using the query that gets weekdays for the current week:
WITH days AS (SELECT - 7 AS d
SELECT d + 1 AS Expr1
FROM days AS days_2
WHERE (d < 7))
SELECT TOP (5) DATEADD(day, d, GETDATE()) AS date, DATENAME(weekday, DATEADD(day, d, GETDATE())) AS Days
FROM days AS days_1
WHERE (DATEPART(week, GETDATE()) = DATEPART(week, DATEADD(day, d, GETDATE())))
(note I have modified the original code provided by the expert in my previous question by removing the conversion and selecting top 5 to omit the weekend days from my results)
What I would like to do now is pass in a parameter rather than use GetDate(), so that the query become get me the weekdays where the date I am passing in i.e. the parameter @date is in that week, as before I want dates back and day names not the day's number.
I hope someone can help, many thanks in advance.
As an afterthought I also want to be able to increment through the weeks - is that possible?