0

2.23:48:50在报告服务字段中有一个列值为 (day.hour:minute:second)。

我尝试使用以下代码进行转换:

(Fields!hrs_apprvd.Value/60) + ":" + (Fields!hrs_apprvd.Value - ((Fields!hrs_apprvd.Value/60) *60) + ":00

格式(DateAdd("s", (TimeSpan.FromTicks(Sum(Fields!hrs_apprvd.Value))), "00:00:00"), "HH:mm:ss")

但它没有用。

我需要将其显示为71:48:50.

如何在 Reporting Services 中执行此操作?

4

1 回答 1

3

Unfortunately your requirements are quite difficult:

  1. Split string into three components based on different delimiters
  2. Convert various components to integers and apply arithmetic to these
  3. Concatenate all the different components to get one adjusted string

Based on this the following expression will work:

=CInt(Left(Fields!hrs_apprvd.Value, InStr(Fields!hrs_apprvd.Value, ".") - 1))
  * 24
  + CInt(Mid(Fields!hrs_apprvd.Value
    , InStr(Fields!hrs_apprvd.Value, ".") + 1
    , InStr(Fields!hrs_apprvd.Value, ":") - InStr(Fields!hrs_apprvd.Value, ".") - 1))
  & ":" & Right(Fields!hrs_apprvd.Value
      , Len(Fields!hrs_apprvd.Value) - InStr(Fields!hrs_apprvd.Value, ":"))

enter image description here

enter image description here

This works for your one example but you might need to adjust slightly for your larger dataset.

You could also simplify the expression by adding a set of calculated fields for smaller expressions like Left(Fields!hrs_apprvd.Value, InStr(Fields!hrs_apprvd.Value, ".") - 1) and then reference the calculated field in the table expression.

You can see the expression gets complicated very quickly - applying the transformation out of SSRS would also be worth investigating.

于 2014-03-18T12:16:41.160 回答