SQL 将订阅中的 Reporting Services 参数值设置为当前日期

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4859695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 09:08:16  来源:igfitidea点击:

Set Reporting services parameter value in subscription as current date

sqlreporting-servicesparameters

提问by Helen

In reporting services SQL server , when I created a subscription for a report with parameter as date time type, I don't know how to set up value of the parameter as current date (wherever the subscription is running).

在 Reporting Services SQL server 中,当我为参数为日期时间类型的报表创建订阅时,我不知道如何将参数值设置为当前日期(无论订阅在哪里运行)。

I tired Today(), Today, today, @ExecutionTime. But none of them worked for me. Only a specific date worked eg: “11/11/2010 00:00:00”.

我累了今天(),今天,今天,@ExecutionTime。但他们都没有对我来说有效。只有特定日期有效,例如:“11/11/2010 00:00:00”。

I also tried to hide the parameter but the subscript still required to fill the parameter. For the "default value” textbox did not allow the value “Today()”, “Today”, etc.

我也尝试隐藏参数,但仍需要下标来填充参数。对于“默认值”文本框不允许值“Today()”、“Today”等。

Thanks in advance!

提前致谢!

Helen

海伦

回答by gbn

You need =to make it an expressions

你需要=让它成为一个表达式

= Today()

回答by Jody

You can't put "=today()" in the text box prompt at runtime. You have to setup the parameter's default value as "=today()" in visual studio.

您不能在运行时将“=today()”放在文本框提示中。您必须在 Visual Studio 中将参数的默认值设置为“=today()”。

回答by Krishna

Try Data Driven subscription and pass a SQL Statement to return the current date for the parameter value.

尝试数据驱动订阅并传递 SQL 语句以返回参数值的当前日期。

回答by Tester

The following code worked on my case:

以下代码适用于我的案例:

parameter1.Value = Date.Today() 

回答by Diego

On the report parameter configuration (on development time, not on the subscription creation), add a default value for the parameter. If you do, you will have a check box called "use default value" when creating the subscription

在报告参数配置上(在开发时,而不是在订阅创建上),为参数添加一个默认值。如果这样做,则在创建订阅时将有一个名为“使用默认值”的复选框

回答by Sarah

If you want to default the report parameter to the current date in the short format, you can set the default value of the parameter to the expression:

如果您想将报表参数默认为短格式的当前日期,您可以将参数的默认值设置为表达式:

=CDate(FormatDateTime(Now, DateFormat.ShortDate))

=CDate(FormatDateTime(Now, DateFormat.ShortDate))

回答by Helen

Actually I did that in visual studio and it worked well in preview (display the current date by default for the parameter and allow people to select other date) .

实际上,我在 Visual Studio 中做到了这一点,它在预览中运行良好(默认情况下显示参数的当前日期并允许人们选择其他日期)。

But for some reason, the subscription setting still asked me for the parameter value (as in the early post "Report Parameter Values").

但出于某种原因,订阅设置仍然要求我提供参数值(如早期帖子“报告参数值”中所示)。

回答by user599237

I tried it as well but it did not work for the subscription.

我也尝试过,但它不适用于订阅。

Sorry I can not attach the screen shot in the post currently.

抱歉,我目前无法在帖子中附上屏幕截图。

In Subscription screen shows: Report Parameter Values
Specify the report parameter values to use with this subscription.
Date To = Today()

在订阅屏幕显示: 报告参数值
指定要与此订阅一起使用的报告参数值。
日期到 = 今天()

Regards,

问候,

Helen

海伦