According to https://learn.microsoft.com/en-us/sql/reporting-services/tutorial-add-a-parameter-to-your-report-report-builder, try replacing -60 (or just 60) with @NumberOfDays.
SQL Query:How to use a variable for number of days in a DATEADD expression.

Joe Frisbie
21
Reputation points
I am not so good at SQL, however, I am trying to take a DATEADD expression we use in an SCCM SSRS report
"Where GSWS.[LastHWScan] >= DATEADD(DAY, -60, GETDATE()) "
And change the -60 entry to use a variable "@NumberOfDays" we prompt for when running the report.
Accepted answer
-
Viorel 89,136 Reputation points
2022-02-03T22:07:02.877+00:00 1 additional answer
Sort by: Most helpful
-
Joe Frisbie 21 Reputation points
2022-02-04T16:38:23.503+00:00 Thank you all, it works. Now I have to understand how to add the variable as a dataset in SSRS to put it all together.
-
Hi @Joe Frisbie ,
Helped convert Viorel-1's comment as answer.
As Viorel-1 said, you may replace -60 with @NumberOfDays.
If this helps on your issue, you could mark it as answer so other user with similar problem could see this easier. :)
Regards,
Zoe
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Helped convert Zoehui-MSFT's response to comment, as it should be