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.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.).