How to convert Generic value into Date and Time format

I am using Get Row Item activity to get value from Data table which read from Excel file, but while reading with String it is not giving output and with Generic value gives output in general format which I want to convert into Date and time format.
Excel Actual Value - 1/10/2023 12:00:00 PM
while reading with Generic value - [44936.7083333333]
So, when I am trying to convert from Generic value to Date gives error as - Assign: String was not recognized as a valid DateTime.

I tried with below code



My simple requirement is read Excel cell value one by one as it is without changing any format.

Can anyone please help to fix this.

Why are you reading it as generic value? @nilesh.mahajan

Hello Sudharsan,

reading with String & Date & Time datatype getting Exceptions, So I tried with Generic value.

What kind of exceptions? Can you share those here ? @nilesh.mahajan

With Date & Time type -
Get Row Item: DateTimeConverter cannot convert from System.Double.
With String type -
Get Row Item: StringConverter cannot convert from System.Double.

You are using the Get row item inside the for each row in datatable right? @nilesh.mahajan

You can directly get that CurrentRow(“Date”).ToString

Have you tried that way?


Hi @nilesh.mahajan ,
If the datetime format you are getting from get text is in this format dd\MM\yyyy assigned to timeValue variable of type generic
use like this buddy
dateVar = Datetime.ParseExact(timeValue.ToString,“dd\MM\yyyy”,System.Globalization.CultureInfo.InvariantCulture)

or if that get text value is in this format dd-MM-yyyy assigned to timeValue variable of type generic
use like this
dateVar = Datetime.ParseExact(timeValue.ToString,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture)

Warm Regards,
Shubham Dutta

In addition to above. When different scenarios are to handle, we can start as described here:
:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

And extend it also for the OADates as introduced here:

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