I am looping through a datatable and I have an IF condition to check if ColumnA=A. If that specific condition is met for the current row, there is another IF condition. This one is meant to check if there are any other rows in which Column=A and the date (ColumnB) is smaller than the current row’s date.
This is what I tried, but I’m getting an error: datatable.AsEnumerable().Any(Function(x) (Datetime.ParseExact(x(“ColumnB”).ToString,“M/d/yyyy”,System.Globalization.CultureInfo.InvariantCulture) < datetime) And (x(“ColumnA”).ToString.Equals(“A”)))
in which datetime is the time variable found in the current row and M/d/yyyy is the date format found in the datatable
Sure, you can add a where statement to select only rows that contain a “/” indicating it’s a date (assuming that the one problematic row does not have a slash)
datatable.AsEnumerable().where(function(x) x("ColumnB").tostring.contains("/")).Any(Function(x) (Datetime.ParseExact(x(“ColumnB”).ToString,“M/d/yyyy”,System.Globalization.CultureInfo.InvariantCulture) < datetime) And (x(“ColumnA”).ToString.Equals(“A”)))