I have two durations in my code. And I want to add them to get the total duration.
Many code examples add some durations to a date, but I have here two durations.
$startOfAnalysis = $(Get-Date)
#Analysis code here
$analysisDuration = $(Get-Date) - $startOfAnalysis
$totalAnalysisTime = "{0:HH:mm:ss}" -f ([datetime] $analysisDuration.Ticks)
$totalAnalysisTime #Outputs similar to 00:16:21
$startOfExecution = $(Get-Date)
#Execution code here
$executionDuration = $(Get-Date) - $startOfExecution
$totalExecutionTime = "{0:HH:mm:ss}" -f ([datetime]$executionDuration.Ticks)
$totalExecutionTime #Outputs similar to 00:13:39
#($totalAnalysisTime+$totalExecutionTime) How to add the two to get 00:30:00?
How do I sum it up to make it to 30 minutes, i. e. 00:30:00?