Unable to format string value in DateTime format using Format Value activity

Hi,

I am trying to format a Generic value which is in Date format i.e. “31/12/2017” using Format Value activity but UiPath throws an error stating Cannot Convert Generic Value to Syste.DateTime

Please assist if I need to format a generic value to datetime format of “MM/dd/yyyy”

Regards,
Ashish

Hi @Ashish32229,

Generic value → genValue (31/12/2017)
DateTime.ParseExact(genValue.ToString(),"dd/MM/yyyy",Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")

Regards,
Arivu :slight_smile:

Hey Arivu,

Thanks for response but I need to format using Format Value activity… Is that possible?

Above way is already used by me but was checking for Format value activity.

It will not support in Format to Date time value, so use the below one.

Regards,
Arivu :slight_smile:

is it possible to convert date to OA date format ?

because I want to compare my date to all the dates in excel, so when I read Range date column, it gives me all the OA dates, so if conversion of date to OA date is possible then it would be easy for me to simply convert my date into OA date and compare them.

Hi @samir

I didn’t test it, but you could check this method:

hey @loginerror
thanks for the reply, :slightly_smiling_face:
yes! I got it, I used this:
system.DateTime.Today.ToOADate.ToString

1 Like