4
我有一個客戶想要在他們的報告基礎上顯示報告的執行時間。爲了適應他們,我已經創建了一個變量上的報告(下報告屬性)被稱爲「GroupExecutionTime」下面的表達式:如何使用日期時間獲取毫秒數?
=System.DateTime.Now
然後在報告的頁腳我有以下幾點:
="Execution Time: " +
IIf(Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).TotalSeconds < 1, "0 seconds",
(
IIf(Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Hours > 0, Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Hours & " hour(s), ", "") +
IIf(Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Minutes > 0, Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Minutes & " minute(s), ", "") +
IIf(Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Seconds > 0, Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Seconds & " second(s)", ""))
)
不幸的是客戶回來說他們希望我顯示報告在不到一秒的時間內執行的毫秒數。這是一個低優先級的要求,但好奇心和希望滿足要求讓我想知道如何做到這一點?不幸的是,System.DateTime.Now
似乎不能在幾秒鐘內存儲任何東西。
修正了以下(感謝安東尼Sottile的答案)
="Execution Time: " +
IIf(Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).TotalSeconds < 1, "0." & Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Milliseconds & " seconds.",
(
IIf(Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Hours > 0, Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Hours & " hour(s), ", "") +
IIf(Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Minutes > 0, Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Minutes & " minute(s), ", "") +
IIf(Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Seconds > 0, Variables!GroupExecutionTime.Value.Subtract(Globals!ExecutionTime).Seconds & " second(s)", ""))
)
我敢肯定,我嘗試過這種嘗試以某種形式或另一種形式...我很快拒絕吃午飯,但我會對我回來的這一個進行破解。 – Codingo
那真是令人尷尬!我一定是第一次拼錯了。不勝感激! – Codingo