Datetime format in datatable

Hi @Kumar802

Can give a try with this expression

Dt1.AsEnumerable.Where(Function(r) DateTime.Parse(r("initial date").ToString).Equals(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"))).CopyToDataTable

Regards
Gokul

so I assume that you must always know in advance what date format you expect.

And that if you change the excel format, the robot will not handle the date correctly.

One idea: if I insert a regex like - Where d(“initial date”) \d{1,2} in the where clause, so that only values containing two digits are filtered out?

You don’t really need to filter anything out. ParseExact will work or it won’t, depending on if the string matches the format(s).

If your source data can contain ambiguous formats/values, then you need to improve the source data so it’s a consistent, known format.

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