I wanted to filter out a date range(Variable type : String) in DataTable

Hello Team. I have attached my excel along with this thread. Please refer the attachment. In the excel Column Name (“Column-8” of type - String) contains dates. I would like to filter and keep only records that is present from July-01-2022 to Current date.

PS: Please provide a solution to filter in DataTable variable type and not filtering using Excel shortcuts


How about the following expression?

dt = dt.AsEnumerable.Where(Function(r) If(DateTIme.TryParse(r("Column-8").ToString,New DateTime),DateTime.Parse(r("Column-8").ToString)> New DateTime(2022,7,11) AndAlso DateTime.Parse(r("Column-8").ToString)<Now ,False)).CopyToDataTable



Thanks @Yoichi . This worked.

1 Like

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