Reputation: 1062
I have a report that runs embedded SQL that uses a simple @startDate and @endDate parameter and the variables in a WHERE clause:
And DM.FromDateTime Between @startDate AND @endDate
What I would like to accomplish is to have an additional parameter that would return only the day of the week the user selected.
For example, if the user chose 3/1/2015 to 3/31/2015 as their date range and selected 'Monday', the report would only populate with data from 3/2, 3/9, 3/16, 3/23, and 3/30.
I know SQL has datepart (dw)
function, but any advice on how to handle this parameter?
Upvotes: 0
Views: 396
Reputation: 86
Create a new integer report parameter @DayOfWeek. It's available values are:
'Sunday' = 1
'Monday' = 2
'Tuesday' = 3
'Wednesday' = 4
'Thursday' = 5
'Friday' = 6
'Saturday' = 7
Then your where clause is simply:
And DM.FromDateTime Between @startDate AND @endDate
AND DATEPART(WEEKDAY, DM.FromDateTime) = @DayOfWeek
Upvotes: 1