- Add a new report variable named thisTime with value of =DateTime.Now
- Add the following code snippet to the Report Code section:
Public Dim execText As String
' for this function to work,
' the following Report Variable needs to be defined and set.
' thisTime =DateTime.NowPublic Function LapseTime(execTime as Date, sysTime as Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.Variable) As String
Dim ElapsedMins As Integer
Dim ElapsedSecs As IntegerDim currTime As System.DateTime = sysTime.Value
If (ExecText = "") Then
'Calculate execution time here
ElapsedMins = DateDiff(DateInterval.Minute, execTime , currTime) mod 60
ElapsedSecs = DateDiff(DateInterval.Second, execTime , currTime) mod 60execText = ElapsedMins.ToString() & "m " & ElapsedSecs.ToString() & "s"
'execText = ElapsedMins.ToString() & ":" & Right("0" & ElapsedSecs.ToString(), 2)
End IfReturn execText
End Function
- To use it, create a new textbox and enter the following in the Expression:
=Code.LapseTime(Globals!ExecutionTime,Variables!thisTime)
- Done!
Collection of Tech Tips found all over the internet that I used in a single location, so I can find them. :)
Monday, June 7, 2021
Report Elapsed Time for SSRS report
Labels:
SSRS
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment