RGT
April 28, 2022, 10:24am
1
I have a datable which contains three columns, Column one is a list of date in which, I need to check it’s contents if it matches with all of the items in an array. For example
Array Contains {1,2,3}
DataTable Column One Contains{1,2,3,4,5,6}
I want to filter out the Datatable where to row with value {5,6} is not present. Both the array and data column items are dynamic.
Hi @RGT ,
We would require to know How the formats of Date are appearing in both the Array and in the Datatable.
This is required to Convert it to a Proper DateTime value and then Compare between the Array and Datatable Column.
For Inspecting the Date Formats, you could Check with the Write Line or use Debug.
Or you could simply provide us with the Sample Input file and the Dates present in the Array.
RGT
April 28, 2022, 10:38am
3
I always convert them first to Short Date String. They all start from string so I do
Convert.toDateTime(var).ToShortDateString
@RGT , Could you try the below Expression :
arrayRow = DT.AsEnumerable.Where(Function(x)Not(dateArray.Any(Function(y)CDate(y)=CDate(x("YourDateColumn").ToString)))).ToArray
here arrayRow
is a variable of Type Array of DataRow, and DT
is the Input Datatable, dateArray
is a variable of Type Array of String.
Using arrayRow
we can Check if it consists any rows and then convert it to Datatable.
Following Post Explains the conversion :
This FirstAid Tutorial will describe how a the source contains no DataRows EXCEPTION can be handled.
Introduction
Let’s have a look at the following filter data table scenario:
Name
CCode
Tom
US
Charlotte
FR
Seema
IN
Jean
FR
Assignment:
Filter all rows on a particular Country Code like FR, UK, ES, UK…
Ensure that all CCode data column values are trimmed
Ensure that the Filter check is case insensitive
we can implement it e.g. with the help of a LINQ statement:
dtData.As…
ppr
(Peter Preuss)
April 28, 2022, 10:59am
5
let us know more details on the datatable. Just share the immediate panel result for:
YourDataTableVar
Have a look here on how to do:
This FirstAid Tutorial will describe how DateTime parsing issues can be analyzed and handled.
Click spoiler text when in hurry:
Example
Assignment
Following Excel data will be processed and the corresponding Quarter is to calculate for the particular task date
Input data:
[input_raw]
Quarter Calculation
Quarter = CInt(Math.Ceiling(YourDateTimeVar.Month / 3 ))
Initial Implementation
[initial_flow_raw]
tmpTaskDate = DateTime.ParseExact(row("Date").toString.Trim, "dd.MM.yyyy", Culture…