Query a datatable using linq in uipath and compare values


I’ve been stuck at this problem for a while.
Hope you can help.

I have a datatable which is created trough a excel application scope // read range activity from an excel file.

This excel file consists of the following:

Name Value Description
Date1 01-01-2020 Jan
Date2 10-01-2020 Jan
Date3 10-01-2020 Feb
Date4 13-02-2020 Feb
Date5 13-02-2020 Mar
Date6 12-03-2020 Mar
etc. etc. etc.

What I am trying to do is compare a series of dates (which are located in another datatable) and determine the corresponding description for those dates. I then want to see if this description value matches the one in the datatable from the excel file and return a boolean value.

For example, I am given a date of 10-01-2020 and a date of 15-02-2020.
Todays date would be 03-02-2020.
I would expect the value of 10-02-2020 to have a description attribute of ‘Feb’.
The date of 15-02-2020 would have a description attribute of Mar .
10-01-2020 would return true because its value is feb under description and todays date being 03-02-2020 the current month is feb, 15-02-2020 would return false because this date is after and its value is mar.

How would I realize this in a sequence?
My idea was to use an inner for each loop on on the series of dates and an outer for each loop on the items from the datatable which comes from the excel table.
Then filtering via linq, but I cant get my code right. I have;

dtFromExcelFile.AsEnumerable and I am stuck after this.

Hope my story makes sense.

welcome to the forum

can you please just reformulate your requirements within a more compact and instructive way e.g.

given value: Date1 01-01-2020 Jan
compared with XXX
Evaluration Rule ZZZ

this would help us much

Hi ppr, thanks for the response, i’ll try.

given value in datatable 1 10-01-2020 with description feb
given value in datatable 2 15-02-2020
current date 03-02-2020

15-02-2020 is before date6 but after date 5. But its also after current date.

evaluation rule;

If given date from datatable 2 is in the current month (datetime.now.month.tostring(‘MMM’)
and this current month value also corresponds to the value for description in datatable 1 when using the date from datatable 2 and finding the 2 dates its situated in between then return true, otherwise return false.

do this for every date from datatable 2.