我目前有一个SSRS报告,该报告每天使用以下SQL代码运行。但是,当复制下降而我们错过了一天时,我们的法院人士希望能够通过进入日期1来手动运行丢失的日期。
我需要一些帮助来设置参数@StartDate,该参数将在下面运行代码。
我有此SQL:
Select *
from Court
WHERE
case_filed_dt =
CASE WHEN datepart(weekday,getdate())= 2 THEN
datediff(day,3,getdate())
ELSE
datediff(day,1,getdate())
END
Order by court asc
简单的案例语句,查看报告的日期运行的日期,如果它在周一运行,则可以在星期五的数据中获取前一天的数据。
我想为我的“ case_filed_dt”字段添加一个参数@startdate,以便手动运行,以防遗漏报告。
示例:
如果我为@startdate = '06 -06-2022'运行,它将像我的案例语句代码一样执行,并获取'06 -03-2022'的数据。如果我为@StartDate = '06 -07-2022'运行,数据将用于6-06-2022'。
谢谢,
杰
I currently have an SSRS report that runs daily with the below SQL code as it should. But, when replication goes down and we miss a day, our Court people would like to be able to manually run a missed date by entering a date #1.
I need some help with setting up the parameter @StartDate, that will run the code below.

I have this SQL:
Select *
from Court
WHERE
case_filed_dt =
CASE WHEN datepart(weekday,getdate())= 2 THEN
datediff(day,3,getdate())
ELSE
datediff(day,1,getdate())
END
Order by court asc
Simple case statement that looks at the date the report is run, if it runs on Monday's, it get Friday's data otherwise previous day's data.
I would like to add a parameter @startdate for my "case_filed_dt" field, to run manually, in case a report is missed.
Example:
If I run for @startdate = '06-06-2022' it will do as my case statement code does, and get data for '06-03-2022'. If I run for @startdate ='06-07-2022', data is for 6-06-2022'.
Thanks,
jer
发布评论
评论(2)
我会保持这个简单。
更改您现有的数据集查询以接受类似的参数(
pstartdate
)。然后,在您的报告中,将参数的默认值设置为表达式为一个
表达式它将使用
today()
作为开始日期,或者如果报告手动运行,则可以由用户选择任何日期。I would keep this simple.
Change your existing dataset query to accept a parameter (
pStartDate
) like this..Then in your report, set the parameter's default value to be an expression
Then if the report is run as normal with no parameters passed, it will use
Today()
as the start date or if the report is run manually, any date can be selected by the user.小提琴上的一些版本应该可以让您开始,该版本使用一个变量来模拟案例语句的效果。
更改日期,然后查看发生的情况
a few versions on the fiddle, which should get you started, this one using a variable to simulate the effects of the Case statement.
Change the date and see what happens
https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=b3ae703d3be9ace930822f7e20230018