I want to apply filter in this column with 2 months and 3 months advance from current month. For ex: I need to filter with 11/01/2025 and 12/01/2025, how can we do this?
Hi, @Nitesh Try this in your Assign activity:
filteredDT = MainDt.AsEnumerable.Where(Function(r) DateTime.Parse(r(“BCD”).ToString) = New DateTime(2025, 11, 1) Or DateTime.Parse(r(“BCD”).ToString) = New DateTime(2025, 12, 1)).CopyToDataTable
This will filter your table for rows with BCD as 11/01/2025 or 12/01/2025. Make sure your Excel dates are in the “MM/dd/yyyy” format. This should solve your filtering problem.
Above code is working fine, but I have other columns (approx 7 columns) which I am filtering with this. How will I make sure to pass the above “filteredDT” in activity Filter Datatable?
@Nitesh After you get your filteredDT using Assign and LINQ, you can pass that filteredDT straight into the Filter Data Table activity to keep filtering other columns.
For dynamic dates, just create variables like:
twoMonth = New DateTime(Now.Year, Now.AddMonths(2).Month, 1)
threeMonth = New DateTime(Now.Year, Now.AddMonths(3).Month, 1)
and use those in your filter expression. This keeps your workflow flexible and updates the dates every time you run it.
Please Mark solution if it was helpful.
Cheers
Solution: I assigned your LINQ in 1 variable and stored in data table variable (filteredDT) → In filter datatable, I used filteredDT as an input (instead of passing MainDt) and got the result.
NOTE: I didn’t passed filteredDT into my filter datatable activity. (Removed from there as I was already having filtered values after using LINQ).
@Nitesh
Awesome, glad it worked for you! Thanks for letting me know. If you ever get stuck again or need help with something else, just reach out. Happy automating!