SSRS计算字段跳过NULL

时间:2014-10-30 11:52:20

标签: reporting-services time

我正在尝试在SSRS报告中进行一些计算。 我有时间在小时:“08:25:21”,其中一些是NULL。

工作:

=IIF(IsNothing(Fields!Hours.Value), Nothing,Fields!Hours.Value)

我想从那时开始提取小时数: 空白错误:

=IIf(IsError(Hour(Fields!Hours.Value.toString())),Nothing,Hour(Fields!Hours.Value.toString()))
=IIf(IsNothing(Fields!Hours.Value),Nothing,Hour(Fields!Hours.Value.toString()))

我怎么能这样做,所以当没有Hours.value时我会得到什么?

丹尼

1 个答案:

答案 0 :(得分:0)

如果小时字段是 TimeSpan ,则可以使用TimeSpan.Hours属性。

我已经能够adding a function to the code of the report完成这项工作。

Function GetHours(timeSpan as TimeSpan) As String
    If timeSpan = TimeSpan.Zero
        Return Nothing
    Else
        Return timeSpan.Hours
    End If
End Function

现在您可以使用此表达式:=Code.GetHours(Fields!Hours.Value)