简体   繁体   English

使用#error,IIF日期的SSRS表达式失败

[英]SSRS expression fails for IIF date with #error

A stored procedure is included in a report builder file of type rdl. 存储过程包含在rdl类型的报表生成器文件中。 the stored procedure has many fields. 存储过程有很多字段。 One of the fields returns a date (not datetime). 其中一个字段返回日期(不是日期时间)。 The desired outcome in the report is to show the date only and empty field if no date is returned. 报告中的期望结果是仅显示日期,如果没有返回日期则显示空字段。

With just the field value the result shows empty field when the date is null otherwise shows the date with a datetime value. 仅使用字段值,当日期为空时,结果显示空字段,否则显示具有日期时间值的日期。

Using IIF to check the value for 'nothing' as shown below. 使用IIF检查“无”的值,如下所示。

=IIF(Fields!myDate.Value Is Nothing,"",Fields!myDate.Value)

The output is the same. 输出是一样的。 A datetime value is shown when date is available. 日期可用时显示日期时间值。

Attempting to use the shortDateString() function yields the correct result in when a date is present but #Error when a date is NOT present. 尝试使用shortDateString()函数会在日期存在时产生正确的结果,但是当日期不存在时会产生#Error。 This is the statement: 这是声明:

=IIF(Fields!rlsPromoDate.Value Is Nothing, "", 
Fields!rlsPromoDate.Value.ToShortDateString())

The version below was attempted. 尝试了以下版本。 No errors resulted however the date was not returned but this was "Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.FieldImpl". 没有出现错误,但没有返回日期,但这是“Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.FieldImpl”。

=IIF(Fields!myDate.Value Is Nothing,"", String.Format("{0:MM/dd/yyyy}", 
Fields!myDate))

Please advise if there is a solution. 请告知是否有解决方案。

Try the following: 请尝试以下方法:

=IIF(Fields!rlsPromoDate.Value Is Nothing, "", Format(Fields!rlsPromoDate.Value, "dd/MM/yyyy"))

or whatever date format you'd actually like to use. 或者您想要使用的任何日期格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM