DateDiff如果SSRS除非为NULL

时间:2013-11-29 15:13:23

标签: sql reporting-services null reporting

所以,我试图让DateDiff工作,但只有当其中一个项不为null时。我有

=DateDiff("d",Today,Fields!Seller_Approval_Date.Value)

但如果Seller_approval_date为null,我希望它显示N / A.

我希望它显示以下内容,但我希望它显示今天和显示日期的差异:

Display error

2 个答案:

答案 0 :(得分:1)

如果您想在报告服务中执行此操作,则可以使用

=Iif(IsNothing(Fields!Seller_Approval_Date.Value),"N/A"
,DateDiff("d",Today,Fields!Seller_Approval_Date.Value))

或者如果不起作用,您可以尝试与值的长度进行比较。

=Iif(Len(Trim(Fields!Seller_Approval_Date.Value)) = 0
,DateDiff("d",Today,Fields!Seller_Approval_Date.Value),"N/A")

最终工作表达

=Iif( IsDate(Fields!Seller_Approval_Date.Value), 
DateDiff("d",Today,Fields!Seller_Approval_Date.Value), "N/A" ) 

答案 1 :(得分:0)

尝试

=ISNULL(DateDiff("d",Today,Fields!Seller_Approvale_Date.Value), 'N'A')