Matching an array and data table

Hi everyone,

I have an array and data table consists of dates. I want to check if the dates that are in the data table match with the array. Then, it prints “arrayDate=Tabledate” therefore, it matches. Else, it prints the dates do not match

getting the datatable column value into an array we can do

arrDataDates =

YourDataTableVar.AsEnumerable.Select(Function (x) x(YourColNameOrIndex).toString.Trim).toArray

so with the in your other topic mentioned Set Operation options we can check for the present/absent values

when implementing your case within a for each row we can do:
For each row in datatable

  • IF: arrDate.Contains(row(YourColNameOrIndex).toString.Trim)
    • then: do actions for the matcher
    • else: do actions for the non matchers


I am using Dt.AsEnumerable.Select(Function (x) x(Dt.Rows(“Date”).toString.Trim).toArray). However, I am getting implicit conversions from string to integer error

1 Like

Hey @RPA_Path

Kindly try the below,

Foreach Row in DataTable

   If dateArr.Contains(Row("Date").ToString.Trim)

         Print "Match"


         Print "No Match"

Hope this helps.



Above expression is wrong. It should be like below.

Dt.AsEnumerable.Select(Function (x) x("Date").toString.Trim).toArray


Here you are trying to loop one by one item from DataTable and checking against the array. If the value match then it will go to the Then part else Else part.

1 Like

I see where it went wrong, thank you.

1 Like

One more question, is it possible to log the dates that were matched instead of the word “match”?


Yes you can. Write below expression in Log Message activity.

1 Like

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