Converting time

Hello All!

I am working on automating a bot where it pulls response times for agents but the response time formats come into excel columns like “2 mins 5 secs” which I then need to convert to a time format like mm:ss or “2:05”

I’m not finding a way to get that done, any help would be appreciated!

Is it always “X mins Z secs”?

If so, then split on space. The 0 index is your mins, 2 index is your secs:


myMin = CInt(myStr.Split(" “c)(0))
mySec = CInt(myStr.Split(” "c)(2))

Output = If(myMin.ToString.Length = 1,“0” + myMin.ToString,myMin.ToString) + “:” + If(myMin.ToString.Length = 1,“0” + mySec.ToString,mySec.ToString)

The If(param1, param2, param3) is just an easy way to pad with the leading 0 if it’s just a 1 digit number.


@Stephen_Delatoba - Another Solution…

String.format("{0}:{1}","2 mins 5 secs".split(" "c)(0).Trim,"2 mins 5 secs".split(" "c)(2).Trim.PadLeft(2,"0"c))

“2 mins 5 secs” - Replace this with row(“your column Name”).tostring

That’s a good single-statement way to do it. Very nice.

1 Like

I am working in studiox for this one. And for further clarification each row in excel will have a unique time, so I’m looking to convert all times to the mm:ss format. Thank you!

Yes but will the format always be “X mins Z secs”?

If so, our solutions will work. If not, you’ll have to give us more info on the different formats it might see.

@Stephen_Delatoba - You can try something like this in StudioX