How to Remove Time Stamp from Date taken from Excel

activities

#1

Hi All,

I’m just starting off in UiPath and wondered if anyone could help me solve this.

I am looking to take a date from excel and input into a desktop application using UiPath. I have formatted the cell in Excel to be “mm/dd/yyyy”, but when the date is transferred it comes in as “mm/dd/yyyy 00:00:00”.

Is there a way to remove this time stamp using UiPath?

I’m currently using the function Type Into and “Effective” in my date variable.

image


#2

Hi,

the full timestamp is good. You can just format it to how you want using date functions like Year(date) or Month(date) or the preferred way you can use .ToString(format), like datetime.ToString(“MM/dd/yyyy”)

So you can get rid of the time by using different format methods.


#3

Hi @TSummers1,

If your variable is of String type, try to assign your variable to something like this:
DateTime.ParseExact(Effective, "MM/dd/yyyy", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")


#4

Thank you for the responses @ClaytonM and @acaciomelo.

Currently, I have the below. Assigning my variable Effective to a column in my excel file called Effective Date.

image

When I attempt to parse the date, I get an error and cannot see how the link between my variable and excel file is being captured.

I’m sure I am missing something, apologies but can you help explain a little bit more?


#6

Hi, try replacing CultureInfo with System.Globalization.CultureInfo.InvariantCulture


#7

Hi @ClaytonM,

The “assign” function no longer gives me an error, I just encounter a new error when running the bot.

image


#8

Not sure about that error. What is Effective outputting right before that activity?

Also, to get the ParseExact to work it looks like you need the adjust the format to include the time.

DateTime.ParseExact(“08/24/2017 00:00:00”, “MM/dd/yyyy 00:00:00”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)


#9

This is the first instance of Effective, so it is not outputting anything at that time.

Main.xaml (42.2 KB)


#10

Looks like you need to store Effective to something before performing that assign. If you are wanting to store it after the assign then you would need to use an If condition to get around the error.
For example:
Assign Effective = If(Effective=Nothing,Nothing,DateTime.ParseExact(Effective, “MM/dd/yyyy 00:00:00”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”))


#11

@ClaytonM - that worked! I just stored the variable Effective twice, thanks for your help!

image

image

image