Dates that need to be compared

Hello.
I have a column with dates that need to be compared so that it displays only the dates that are different and not repeat them?

Hi @teslyak9437

Can you try the below

dt.AsEnumerable() _
    .GroupBy(Function(row) row.Field(Of String)("Dates")) _
    .Select(Function(Group) Group.First()) _
    .CopyToDataTable()

Input:

Output:

image

Or

Use Remove Duplicate Rows activity

Cheers!!

Hi,

FYI, another approach using Remove Duplicates activity:

Sample
Sample20240509-8.zip (16.3 KB)

there is more information in the file and it cannot be deleted using the Remove Duplicates activity.

but in the input just specify your column range not entire sheet so specifying only date column should solve this issue

@tracy.ball You also can get the record using the Distinct() Function using code

This is just a sample file you need to change according to your input file.

var distinctDates = dataTable.AsEnumerable()
                              .Select(row => row.Field<DateTime>("Your Column name"))
                              .Distinct()
                              .ToList();

Are you saying you want to blank out the date for the rows where it’s duplicated, to keep the rest of the data for the row?

Honestly, you shouldn’t do this - it’s poor data design. What is your overall goal with the automation?

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