Change the format of Timespan Variable

Hello All,

I am using a workflow where i need to find out the time taken to complete a specific task,
so i have used 2 variables of Data type : Datetime (“startTime” and “endTime”) and 1 Variable of Data Type : TimeSpan (“executionTime”)
So before the start of task i have assign value of startTime = DateTime.Now and at the end of task value of endTime = DateTime.Now
Now in order to get execution time i have assigned executionTime = endTime - startTime.
The output of time span variable is in format D.HH:MM:SS (Days.hours:Minutes:Seconds)
but i want the output in HH:MM:SS only.

Also the Task may take 1 or 2 days to complete .

Please let me know any solution for above query.


I think you can do that like this (similar to formatting a datetime):

I’m not too sure though.

here is some info, or do another search yourself:

1 Like

If you don’t want the days and want total hours instead, use the TotalHours property of the timespan. (e.g. If the process takes 1 day, 12 hours, 15 minutes, and 12 seconds, you want the format of 36:15:12). Use something like this:

System.Math.Floor(variable.TotalHours).ToString & variable.ToString("\:mm\:ss")