Date conversion from excel value saved as number

Hello,
I am trying to convert the following Date from excel to DateTime but I get this error:
Conversion from string “44053” to type ‘Date’ is not valid.

Date

UIPath Studio sees the date as string:
UIPAthDate

And this is what i have tried:
Condition

1 Like

Hi,

It’s serial value in excel. Can you try the following?

 DateTime.FromOADate(Double.Parse(cell.ToString))

or

You can get it as string (Not numeric serial value but date string) if you set true PreserveFormat proerty of ReadRange/ReadCell activity.

Regards,

1 Like

Thank you, FromOADate solved my case, I am looking at the preserve format since not all might get that type.

1 Like

Attempting to use the PreserveFormat property. I expected a date string but instead it
was “[$-4442289]m/d/yy h:mm AM/PM”
How can this value be converted to DateTime?

That is OADate time format, and I’ve converted it using this:
Datetime.FromOADate(Convert.ToDouble(cell.ToString)).ToString("MMM-yy").Equals(DateTime.Now.Tostring("MMM-yy"))

1 Like

Thank you! I found that turning off PreserveFormat property the result (44227.6549074074) can be assigned to Double and convert with DateTime.FromOADate as you suggested.