[英]Reporting Services, getting error during the arithmetic operation
我試圖在SQL Server Reporting Services中獲得兩個日期之間的差異。 我有離開日期,以及下一個到達日期。 我使用兩個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.
問題出在你的表情部分
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")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.