Hi all,
I have a doubt, I have an excel in Column13 I have dates I need to do filtration I need to filter the date i provide and future dates.
Example- if I give date as 08-03-2024 bot should consider that date and future dates.
How to give this logic in filter data table.
Can you please help me. Thanks in advance
@0bb4628e217fd43ac86ac9294
Step 1: Read Excel File
Use the “Read Range” activity to read the Excel file and store the data in a DataTable.
Step 2: Filter DataTable
Add the “Filter DataTable” activity to your workflow.
Step 3: Configure Filter DataTable
In the “DataTable” property, select the DataTable variable that you read from the Excel file.
In the “Filter Wizard,” set the condition for the date column. Use the expression: "[Column13] >= #" + yourProvidedDate.ToString("MM/dd/yyyy") + "#"
@ISBS_ROBOT
DateTime.ParseExact(str_Variable,“MM-dd-yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-40)
check the thread
I am not getting expected output
Can anyone help me please
pikorpa
(Piotr Kołakowski)
March 12, 2024, 9:39am
5
hey @0bb4628e217fd43ac86ac9294
you can try use linq:
filteredDataTable = originalDataTable.Clone()
filteredDataTable = originalDataTable.AsEnumerable().
Where(Function(row) Not IsDBNull(row("Column13")) AndAlso
DateTime.Parse(row("Column13").ToString()) >= yourDate).
CopyToDataTable()
@pikorpa this is also not working
lrtetala
(Lakshman Reddy)
March 12, 2024, 11:50am
7
Hi @0bb4628e217fd43ac86ac9294
Can you try the below
DT.AsEnumerable().Where(Function(row) DateTime.ParseExact(row("Dates").ToString(), "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture) >= DateTime.ParseExact("08-03-2024","dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture)).CopyToDataTable()
Cheers!!