How to Display the Elapsed Processing Time of a Report in SSRS
How to Display the Elapsed Processing Time of a Report in SSRS
The amount of time it takes to process a report can be useful information for performance auditing. Although there isn’t a built-in field in SQL Server Reporting Services that holds the elapsed processing time, it’s easy to create this functionality using the ExecutionTime built-in field and the Now VB.Net function in SSRS.
For instructor-led SQL Server Training see our complete course schedule.
The ExecutionTime is the moment when report processing starts. When used in the expression of a textbox, the Now function returns the time when the report is rendered. Rendering comes right after report processing. This means we can easily calculate the processing time simply by subtracting Now from ExecutionTime.
Function Implementation
One way to implement the logic is to put it into a custom function and then call the function from the expression of a textbox. This is clean, the code is easy to read and so it’s also easy to maintain. The downside is that you have more than one component to the solution; so, if you want to copy this functionality into other reports, you’ll have to copy and paste both the function and the textbox. My preference would be for this approach because “clean and easy to maintain” usually leads to smoother running programs!
If you’ve never created custom code in SSRS before, read my article on Using Custom Code in SSRS to see how it’s done. Then create the following function that will both calculate the elapsed processing time and return it as a string in the format mm:ss.
1 2 3 4 5 6 7 8 | Function ProcessingTime(StartTime As Date, EndTime as Date) As String Dim ElapsedMins As Integer = DateDiff(DateInterval.Minute, StartTime, EndTime) mod 60 Dim ElapsedSecs As Integer = DateDiff(DateInterval.Second, StartTime, EndTime) mod 60 Return ElapsedMins.ToString() & ":" & Right("0" & ElapsedSecs.ToString(), 2) End Function |
Single Expression Implementation
Another way to implement the logic is to use a single expression in a textbox (right-click the textbox and select Expression…) that does everything. This is a bit messier, the expression has a whole bunch of things piled into it making it harder to read and maintain, but all you have to do to put it into another report is copy just that one textbox containing the following expression, which also displays the results in the format mm:ss.
1 2 | =DateDiff(DateInterval.Minute, Globals!ExecutionTime, Now()) mod 60 & ":" & Right("0" & DateDiff(DateInterval.Second, Globals!ExecutionTime, Now()) mod 60, 2) |
Enjoy!
Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ
You May Also Like
Agile Methodology in Project Management
0 81 0In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management
Creating Users and Managing Passwords in Microsoft Office 365
0 245 2In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.
Detailed Forensic Investigation of Malware Infections – April 21, 2015
2 318 3In this IT Security training video, Security expert Mike Danseglio (CISSP / CEH) will perform several malware investigations including rootkits, botnets, viruses, and browser toolbars.
GREAT !! Thank you!