Linq query to check date in a datatable

Hello Everyone,

I need a Linq query for the following datatable.
Verify the dt with a date and determine between which start date and end date the following date appears.
For example, a random date (07/14/2022; format: MM/dd/yyyy), that is in the 4th row.

Output as dt,
Able to achieve using for each, but it is slow
Thanks in advance


Please check the following query:

From row in YourDataTable
Where CDate(row(“StartDate”).ToString) >= YourDate AndAlso CDate(row(“EndDate”).ToString) <= YourDate
Select row

For more about Filter DataTables, please check the following video:

1 Like

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