How to convert below query from equals to contains

str CheckValu = dt_Schedule.AsEnumerable.Any(Function(r) DateTime.ParseExact(r(0).ToString, “MM-dd-yyyy”, System.Globalization.CultureInfo.InvariantCulture).Date =DateTime.Now.AddDays(-1).Date)

@shilpashree.mohanty

you want to check contains on a date?

what specific data you want to check there?

cheers

Hi, @shilpashree.mohanty

Fallow the steps below. If I helped you, please market it as solved.

To convert the query from equals to contains, you can modify the direct date comparison to check whether the desired date is contained in the result. To do this, you can use the Contains method of the string or adjust the logic for a more flexible comparison, depending on the type of data you want to check.

str CheckValu = dt_Schedule.AsEnumerable.Any(Function(r) r(0).ToString.Contains(DateTime.Now.AddDays(-1).ToString(“MM-dd-yyyy”)))

i want to use the same query to check if the date is contained in the datatable

as value now would be “20/10/2024 Domestic”

@shilpashree.mohanty

you can do this

str CheckValu = dt_Schedule.AsEnumerable.Any(Function(r) r(0).ToString.Contains(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy")))

this will check for date containing format with dd/MM/yyyy

cheers