Job Duration/execution end time

is there any method to get the exact execution end time or even the job duration plus the job start time ?

Depending on what exactly you want to achieve.

For example, the following code snippet will calculate duration between job creation date and last state (e.g. Succeeded) creation date:

IMonitoringApi monitoringApi = JobStorage.Current.GetMonitoringApi(); // or whatever
JobDetailsDto job = monitoringApi.JobDetails(jobId);
TimeSpan duration = job.History[0].CreatedAt - job.CreatedAt;

This is just an example. In the real world, the job might have no history records at all (you need to check that), or have multiple Succeded/Failed states in history (if the job was requeued because of errors etc.).

1 Like