Not valid DateTime

Hello everyone. I have a column in excel that I transform into a Data Table.

My dates are in formats : dd/MM/yyyy

Others (in green) are in MM/dd/yyyy format

I would like to convert these dates (in green) to dd/MM/yyyy format. Here is my flow:
image

Here is the error I get
image

Can you help me? Please ? :slight_smile:

:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

1 Like

Hi,

Data in green cell seems datetime type in excel. If so, the following ForEachExcelRow might help you.

Condition

CurrentRow("date_article").RawValueType =Type.GetType("System.DateTime")

Then

CurrentRow("date_article") = CDate(CurrentRow("date_article").ToString).ToString("dd/MM/yyyy")

Regards,

Hello, thank you for your answer. I tried this however I can’t make my condition, I have this error:

Compiler errors encountered while processing expression CurrentRow(“date_article”).RawValueType =Type.GetType(“System.DateTime”).(2) error BC30574 Option Strict On reject all late bindings

Hello @DimitriLYR
try below. I have modified the @Yoichi code a little bit
CurrentRow("date_article").GetType = Type.GetType("System.DateTime")

1 Like

@DimitriLYR

The code given above works inside a use excel scope…i guess you are trying to do it inside a for each row in datatable…please check

Cheers

1 Like

I actually use a data table.

@DimitriLYR

Then i would suggest use as below

use a try catch around the asign activity where you are converting the date…

In the catch block use another assign but now use DateTime.ParseExact(datestring,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

cheers

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