How To Check grater date in a column using FilterDataTable activity?

Hello experts !

I have a DataTable that has “Xyz” Column name that contains “26/02/2024 10:12:23 PM” all date of process.
I am using filter data table but it is not giving the output but in main datatable there are rows grater than date

Hi @RobotUi

Can you share sample excel and expected output.

Regards

no, i cannot share that.

Hi @RobotUi

May be Dummy data will help me give you query.

Regards

It is possible with LINQ but i am not able to do it with UiPath FilterDataTable activity

Hi @RobotUi

Try this:

filteredDataTable = YourDataTableVar.AsEnumerable().Where(Function(row) DateTime.Parse(row.Field(Of String)("Xyz")) > DateTime.Parse("26/02/2024 10:12:23 PM")).CopyToDataTable()

Hope it helps!!

Hi @RobotUi

Can you tell what format is the date in xyz column and the date you want to compare.

Regards

It is in the same format like this “26/02/2024 10:12:23 PM”. only date and time are different.

Hi @RobotUi

After Read Range is it printing in the same format. Please specify. Please check that and tell.

Regards

yes it is printing in same format and its data type is string.

Hi @RobotUi

Try this:

Dim filteredDataTable As DataTable = YourDataTableVar.AsEnumerable().Where(Function(row) DateTime.ParseExact(row.Field(Of String)("Xyz"), "dd/MM/yyyy h:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) > DateTime.ParseExact("26/02/2024 10:12:23 PM", "dd/MM/yyyy h:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture)).CopyToDataTable()

hope it helps!!

Same Error encountered :

System.FormatException: String ‘’ was not recognized as a valid DateTime. at System.DateTime.ParseExact(String s, String format, IFormatProvider provider)
at

The error indicates that the date you are trying to parse is empty. The column “Xyx” has empty cell values?

Hi @RobotUi

The error indicates the column contains empty values. Does the column have empty values.

Regards

but there is no any empty columns

Hi @RobotUi

Atleast a screenshot would help me to see how the data looke like to provide you the correct query

Hi @RobotUi

Check out the below workflow:
Sequence16.xaml (9.2 KB)

Syntax:

dt_Output = dt.AsEnumerable().Where(Function(row) DateTime.ParseExact(row.Field(Of String)("Process Date"), "yyyy/M/d h:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) > DateTime.ParseExact("2024/02/26 10:12:23 PM",  "yyyy/M/d hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture)).CopyToDataTable()

dt_Output is of DataType System.Data.DataTable

data.xlsx (11.1 KB)
Sheet1 is Input and Sheet2 is Output

Read Range Workbook properties


Write Range Workbook

Hope it helps!!

1 Like

it is copy paste, no any changes in output file