【问题标题】:Reporting Services, getting error during the arithmetic operationReporting Services,在算术运算期间出错
【发布时间】:2018-12-12 17:29:13
【问题描述】:

我试图在 SQL Server Reporting Services 中获取两个日期之间的差异。我有离开日期和下一个到达日期。我在第一个 iif 中使用两个 iif 来计算天数,在第二个 iif 中使用小时、分钟和秒。

=iif(IsNothing(Fields!NextEnterDateTimeUtc.Value)=False,

Floor(DateDiff(DateInterval.Second, Fields!LeaveDateTimeUtc.Value, Fields!NextEnterDateTimeUtc.Value) / 86400)

& iif(Floor((DateDiff(DateInterval.Second, Fields!LeaveDateTimeUtc.Value, Fields!NextEnterDateTimeUtc.Value)) / 86400)=1," day ", " days ") & 

Format(DateAdd("s", DateDiff(DateInterval.Second, Fields!LeaveDateTimeUtc.Value, Fields!NextEnterDateTimeUtc.Value), "00:00:00"), "HH:mm:ss")

, "No data")

问题是,在计算之后,当没有 Fields 的数据时!NextEnterDateTimeUtc.Value,我收到错误:Expression The hidden value in the text "Textbox20.Paragraphs [0] .TextRuns [0]" contains an error: An overflow occurred during the arithmetic operation.

【问题讨论】:

  • 一些发生错误的示例数据可能会有所帮助
  • Fields!LeaveDateTimeUtc.Value1 is 2018-06-08 10:34:15 and Fields!NextEnterDateTimeUtc.Value` 是 2018-06-09 20:35:43 时,一切都计算正确。但是当 Fields!LeaveDateTimeUtc.Value 是 2018-06-09 22:35:44 并且 Fields!NextEnterDateTimeUtc.Value 是 NULL 我收到错误消息

标签: sql tsql reporting-services


【解决方案1】:

问题出在你的表情部分

DateAdd("s", DateDiff(DateInterval.Second, Fields!LeaveDateTimeUtc.Value, Fields!NextEnterDateTimeUtc.Value), "00:00:00")

Iif 计算所有表达式,即使条件为假

您需要额外的 Iif 才能始终为 Dateadd 返回有效值

   DateAdd("s", Iif(IsNothing(Fields!NextEnterDateTimeUtc.Value)=False,DateDiff(DateInterval.Second, Fields!LeaveDateTimeUtc.Value, Fields!NextEnterDateTimeUtc.Value),0)

下面是完整的表达方式

= iif(IsNothing(Fields!NextEnterDateTimeUtc.Value)=False,

Floor(DateDiff(DateInterval.Second, Fields!LeaveDateTimeUtc.Value, Fields!NextEnterDateTimeUtc.Value) / 86400)

& iif(Floor((DateDiff(DateInterval.Second, Fields!LeaveDateTimeUtc.Value, Fields!NextEnterDateTimeUtc.Value)) / 86400)=1," day ", " days ") & 

Format(DateAdd("s", Iif(IsNothing(Fields!NextEnterDateTimeUtc.Value)=False,DateDiff(DateInterval.Second, Fields!LeaveDateTimeUtc.Value, Fields!NextEnterDateTimeUtc.Value),0), "00:00:00"), "HH:mm:ss")

, "No data")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    相关资源
    最近更新 更多