Calculating Script duration in a script

To calculate the duration of a script in either seconds or minutes from within the script follow these instructions.

Start page

Add a database get on the start page containing the following SQL statement;

Select Start_time from tbl_Session with (nolock) where id = [var_csSessionID]

This statement will return the start time for each script run based on the session ID.

you will need to stamp the result into either a hidden field or text box depending on if you want it to be visible.

Wrap page

Add a used control of the field you stamped the start time into, another field to stamp the duration into and a database get with the following SQL statement;

set dateformat dmy Select DATEDIFF (SS, [Start_Time],GETDATE()) as duration

Replace [Start_Time] with the name of your used control from the start page.

You can then stamp the result of this database get into a field to store the duration. If you want to see the duration in minutes you should replace the SS with MI.