Hi,
Having 2 data tables. I need to compare the 2 data tables with below conditions
ID columns values should be equal
2.Date column value from dt1 should be between date1 and date2 from dt2(date>=date1 and date<=date2)
finally output dt get all rows from dt1+matching rows from dt2 like below.
Use assign activity and write the expression in RHS
(From row1 In dt1.AsEnumerable()
Group Join row2 In dt2.AsEnumerable()
On row1("ID") Equals row2("ID") Into GroupJoin = Group
From subRow2 In GroupJoin.DefaultIfEmpty()
Select dtOutput.Rows.Add(
row1("ID"),
row1("Date"),
If(subRow2 Is Nothing, Nothing, subRow2("Date1")),
If(subRow2 Is Nothing, Nothing, subRow2("Date2")),
If(subRow2 Is Nothing, Nothing, subRow2("Comments"))
)).CopyToDataTable()
Join dt1 and dt2 using join dtatable on ID with left join
Now after join you can use linq or filter to get the rows only between required date1 and date2
sample linq to be used in assign joineddt = joineddt.AsEnumerable.Where(function(x) String.IsNullOrEmpty(x("Date1").ToString) OrElse (Cdate(x("Date").ToString)>=Cdate(x("Date1").ToString) AndAlso Cdate(x("Date").ToString)<=Cdate(x("Date2").ToString))).CopyToDataTable
following your steps, for 2nd step while comparing the datetime(MM/dd/yyyy hh:mm:00) above linq query not working in UiPath windows legacy platform(getting Specific cast invalid error) and same query working and getting expected results in UiPath windows platform. Could you please suggest in this.
Note: Used same version of system, excel activities.
TIA.
Date column coming in custom type in excel and other date1 and date2 are in General type. Could you please suggest how to change date column to general type?