Select a Date range using LINQ with Method Syntax

we highly recommend to check on how the dates are present within datatable as described below and also mentioned that it presence does not have the mandatory same format as in the excel file

A LINQ could look like this:

(From d In dtData.AsEnumerable
Let ds = d("OrderDate").toString.Trim
Let dp =DateTime.ParseExact(ds,"dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).Date
Where dp > (#02/13/2024#).Date
Where dp < (#05/15/2024#).Date
Select r=d).CopyToDataTable()

we can dynamize it by using variables instead of e.g. (#02/13/2024#).Date

Handling empty results:

1 Like