Copying DATE from excel to UiPath Studio

Hi everyone,
I applogizse if this is a silly question, but as a newbie, I would appreciate some guidance. I am creating a BOT(my first one). Part of the BOT is to take the date from excel (in a mm/dd/yy format) and copy it into an application in the same format. However, when it does that, it also types the hours, minutes and seconds. I do not need those as it creates an error. In excel, the format is mm/dd/yy. How do I make sure (what do I need to do) that the hours, minutes and seconds are not typed into the field.
image

Hi @rezart_mersini

When you read the excel using Read Range Workbook enable Preserve Format Option in the properties Panel. Then it will take only the format MM/dd/yy.

Regards

1 Like

Hi @rezart_mersini

You can try the split function for this. In your condition after date may be there is a space and time is there. If yes then use the below expression in type into activity,

CurrentRow("LAST DATE").toString.Split(" ").First

It will get the date only from excel and skips time

Hope it helps!!

1 Like

Try below method once
Convert.ToDateTime(CurrentRow(“LAST DATE”).ToString).ToString(“MM/dd/yyyy”)

1 Like

You should do the free training at academy.uipath.com - there’s even a section specifically about Excel.

1 Like

that is something I must do, I agree. Probably next step! Thanks for the suggestion

This worked…I will try the other suggestions to see if they work as well.
Thank You!

1 Like

It’s my pleasure… @rezart_mersini

Happy Automation!!

preserving the format worked as well. However, which option do you think is best practice…

preserving the format or the code below, from @mkankatala

CurrentRow(“LAST DATE”).toString.Split(" ").First
Thanks

It was based on your requirement, the preserve format will give the displayed format values in the cells from Excel.

If you want to use the Expression then don’t use the preserve format. If you want to use preserve format then no need to use the expression. It all based on your opinion.

Both are best practices.

Hope you understand… @rezart_mersini

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.