Adding time using Uipath

Hello,

I have to put data into an excel and I am having trouble adding together some data that will go into the same cell. For example both 05:10:34 and 30:37:37 have to go into the same cell, so they must be added together. They are currently stored as variables of type int32. I was hoping a simple “+” would work but it just put them together: 05:10:3430:37:37. Any help?

Thanks

@deguy42

You do as below

“05:10:34” + " " + “30:37:37”

Variable1.ToString + " " + Variable2.ToString

Hope this may help you

Thanks

1 Like

Hello,

Thanks for the quick reply, I tried this but I still get it grouped together 05:10:3430:37:37.

@deguy42

Can you share the screenshot?

Thanks

What would you like the screenshot of? The Uipath workflow?

your result (wrong output), and your desired output :slight_smile:

Hi @deguy42 ,

Use “’” + Variable1.ToString + " " + Variable2.ToString

admin Mins
Capture

Where admin (minutes) is where these two times should be added together to go. Admin and IT variables are from read cell activities in a separate data excel file and are currently stored as int32 type.

Desired outcome would be the number 35:47:37 in the Admin (minutes) column.

Another question, it isn’t a big deal if this can’t be done, is it possible to use an array or something else to check if the minutes or seconds are above 60 when they have been added together and to then correctly sort that out.

Thanks for all the help

@deguy42

give space in between the double quotes and try

Like Admin.ToString + " " +IT.ToString

Hope this may help you

Thanks

@deguy42 - please check this post…

This (35:47:37) should not be in the int32 type as it is a minute: seconds in your excel. So converting to string or integer will not help at all especially in making the basic calculations. There is DateTime data type in UiPath, I believe you can use it for this if you manage to create a custom format to match the format in your excel.

Hope this may help you

Thanks

Hello,

I tried this but anytime I use timeSpan it says “Compiler error(s) encountered processing expression “timeSPan ts1”. End of expression expected”. I did try to make ts1 DateTime type but it didn’t change the error message.

Problem is that 30 hrs is little tricky. Timespan is not taking that 30 hrs, when I put 23 hrs…it converted fine…

image

1 Like

@deguy42

Check below for your reference

Reference

Thanks

test.xaml (5.3 KB)

Try to use invoke code, hope this will work.

2 Likes

I see, that is awkard, most of the time the value will be above 24 hrs. Would any excel formulas work on this?

Hello,

Thank you for this, I’ve never used invoke code before, do I need to edit parts of this or just run it with my workflow or by itself?

Thank you

@ermanoj3101 - Nice…Quick question…

Ideally , output should be 35:48:11 right??

image

and if I put 57 mins, it is giving still incorrect results…

1 Like

Hi @prasath17 ,

I agree that it is just adding total hours , min and sec.
I think this wouldn’t help.

Thanks.

You have to pass only Admin and IT time and you will get the result.

Just click Edit Arguments to pass your values.

If you want just total of hours, min and sec then this will work.