amachanic / sp_whoisactive

sp_whoisactive
GNU General Public License v3.0
1.17k stars 289 forks source link

Get the duration in seconds (in combination with @format_output) #50

Closed buckleyGI closed 2 years ago

buckleyGI commented 3 years ago

I was wondering if we can get the duration in seconds (for easy filtering or comparison) instead of dd hh:mm:ss.mss e.g. 00 00:00:26.250

It is the elapsed_time that I am after I think. Is it a glitch that it is returned for the evarage but not the normal column?

Formatted: [dd hh:mm:ss.mss] varchar NULL Non-Formatted: For an active request, time the query has been running For a sleeping session, time since the last batch completed

Formatted: [dd hh:mm:ss.mss (avg)] varchar NULL Non-Formatted: [avg_elapsed_time] [int] NULL (Requires @get_avg_time option) How much time has the active portion of the query taken in the past, on average?

erikdarlingdata commented 3 years ago

@buckleyGI I'm having a tough time parsing this request.

amachanic commented 2 years ago

@buckleyGI The reason it's not returned in non-formatted output is that the proc returns start_time and collection_time columns. It should be trivial to use DATEDIFF to come up with seconds, minutes, or whatever sort of resolution you like. The average column is returned in non-formatted mode because we don't have any reference columns there. No glitch :-)