Filter based on condition

How can I filter the datatable where I have datecolumn like this
image
which has different formats

I need to filter the date column where the data are after october(10/01/2019)
Please help

You need to go through the datatable by For Each Row and standardize date format. Then you can use Invoke Code with DataTable Select Function (VB.NET DataTable Select Function - Dot Net Perls). Or you can delete the items with unwanted date in the first For Each Row cycle.

1 Like

@Sweety_Girl
We do have the option to configure ParseExact to work multiple formats on parse:
grafik

Statement:
DateTime.ParseExact(d(0).toString.Trim, Formats, CultureInfo.InvariantCulture,DateTimeStyles.None)

Find starter help here:
DT_FilterByDate_2Formats.xaml (10.6 KB)
Showcasing:

  • parsing check within a foreach
  • filtering - picking up original date
  • filtering - harmonizing date to dd.MM.yyyy
4 Likes

@Sweety_Girl
as discussed by messages I do summarize our last steps:

  • DataTable was populated with a different DateTime format, so we did added to the format array
  • an initial may date was interpreted as a bug. But the date was from next year, so it was after the compair date and is therefore correct

Error analysis can be organized like:

  • inspect the datatable and check for real received dates
  • play within the watch box or test within a for each which date/s is/are breaking
  • fix it or handle it

Updated XAML here:
DT_FilterByDate_2Formats_V2.xaml (14.3 KB)

1 Like

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