简体   繁体   English

SSRS表达式中的SSRS解析日期错误

[英]SSRS Parse Date Error in SSRS Expression

Any idea why getting an #Error using the code below when the field fp_firstshifttimein does not contain value. 任何想法,为什么当字段fp_firstshifttimein不包含值时,使用下面的代码会出现#Error。 But when the field contains value, it works. 但是,当字段包含值时,它将起作用。

=IIF(IsDate(Fields!fp_firstshifttimein.Value), 
DateTime.Parse(Fields!fp_firstshifttimein.Value).addDays(8), Nothing)

Same issue with the code below: 以下代码存在相同的问题:

=IIF(IsNothing(Fields!fp_firstshifttimein.Value), Nothing,
 DateTime.Parse(Fields!fp_firstshifttimein.Value).addDays(8))

Thanks all. 谢谢大家

你可以尝试一下吗?

=IIF(Fields!fp_firstshifttimein.Value is nothing, nothing, DateTime.Parse(Fields!fp_firstshifttimein.Value).addDays(8))

I found out that SSRS evaluates each part of the function before the report is executed. 我发现SSRS在执行报告之前会评估功能的每个部分。 I tried the code below. 我尝试了下面的代码。 It worked. 有效。

=IIF(IsDate(Fields!fp_firstshifttimein.Value),
DateTime.Parse(iif(IsDate(Fields!fp_firstshifttimein.Value) ="1",
Fields!fp_firstshifttimein.Value,"01/01/1900")).addDays(8), nothing)

Use the DateAdd function like this: 使用DateAdd函数,如下所示:

=IIF(IsNothing(Fields!fp_firstshifttimein.Value), Nothing,
    DateAdd("d", 8, Fields!fp_firstshifttimein.Value))

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

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