Extract unique dates from List of dates in Data table

Hi ,

I am trying to extract Unique calendar Years from the dates in a Data table

lets say if i have a data table as below , the expected output would be the unique Years of the data table

Customer Transaction ID Date
user1 108436 27-Jan-23
user2 130071 08-Feb-23
user3 131806 09-Feb-22
user4 131812 22-Feb-23
user5 133330 27-Feb-21

It could be achieved using For loop, but just wanted to see if there is an easier method .

Hi @benjamin.9052

If you need only the unique years from this datatable, here’s the workflow that you can use:
Datefilter.xaml (5.4 KB)
Dates.xlsx (9.5 KB)

expression used here:

String filteredYears= actualDates.AsEnumerable.Select(function (x) DateTime.Parse(x(“Dates”).ToString).Year.ToString ).Distinct.ToArray

Hope it helps.


Happy Automation! :slight_smile:


Use assign activity create a variable of datatype datatable
and in Value section write YourDataTableName.DefaultView.toTable(“Date”,true)

This helps ,

Thank you so much

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