Get Latest Date with Max function from list (of Match)

how to use max function for list of regular.expressions.matches datatype, i am getting multiple date as list (list1) list of datatype as system.
consider dates like { [25.07.2020], [26.08.2020], [26.08.2020], [26.09.2020] }
or may be something like
{ [05.06.2019], [18.09.2020], [26.04.2021], [31.12.2021] }
Assign: At least one object must implement IComparable.

let us be a little more clear on the requirements:

input: the Result of a Regex - IEnumerable(of Match) Or MatchCollection?
Matches: DateTime Strings like: 25.07.2020…
expected: the latest Date as DateTime?

for more better understanding attached pdf
regex in matches activity will be “[0-9]{2}.[0-9]{2}.[0-9]{4}”
to get this output { [05.06.2019], [18.09.2020], [26.04.2021], [31.12.2021] }

So I believe it will be like:
1.input: the Result of a Regex - IEnumerable(of Match) it is s output of matches activity
but when i update in datatable it comes as
ystem.Text.RegularExpressions.MatchCollection
2.Matches: DateTime Strings like: 25.07.2020 ----- Yes
3.Matches: DateTime Strings like: 25.07.2020…in dd/MM/yyyy format
expected: the latest Date as String

Sample document.pdf (27.0 KB)

before doing this
also can we check if all the elements of the list or array are unique ?
list is basically set of dates
{ [05.06.2019], [18.09.2020], [26.04.2021], [31.12.2021] }

@Sakshi_Jain

Ensure Following:
grafik

give a try on following:
Assign Activity
Left Side: MaxDate - DataType: DateTime
Right Side:

YourMatchResultVar.Max(Function (x) DateTime.ParseExact(x.ToString,"dd.MM.yyyy",CultureInfo.InvariantCulture))

for getting the string, just do following:
MaxDate.ToString(“dd/MM/yyyy”)

Sample Project.zip (130.7 KB)

Sharing sample workflow
I am not able get maximum date
and if any two dates are different

ok converting I can do

@Sakshi_Jain
checking it in the immediate panel verifies that the statement is working

ensure that following namespaces are imported:
System.Globalization
System.Linq
System.Text.RegularExpressions

@ppr
List_Date.Distinct().Count <> List_Date.Count
its giving same value even when one value is different and two values are same
so all conditions it showing same dates and value of MulDates is False

List_Date is not storing in datacolumn2
what should be column datatype and how to add data row ?

@Sakshi_Jain
We would like to ask you on following:

  • please keep the different topics clean on one case
    ( in this case: Find latest Date using Max Function in a list)

Other members doing a research on same or similar case will more easy find the solution / discussion. This will helps them on their case work.

As you have created many topics (please also avoid duplicated topics) the different cases are seperated and should be discussed there.

Refering to this case, we would like to see the progress within a pattern:

  • Question
  • Solution / Approach
  • Iteration (if it is needed)
  • Final Testing
  • topic closing by marking the solving post as solution

This cleat pattern allows us to more quick handle many open cases and to identify quickly what is solved and working.

So in this case your feedback on the suggested solution is remaining.

Thanks for your support

1 Like

Sure I will do this
so now for the above two things where do u want me to post on ?

@Sakshi_Jain - Please find the workflow sample and Output MaxDate(31/12/2021)

Here StrOuput is of variable type = MatchCollection

System.Text.RegularExpressions.Regex.Matches(StrInput,"[\d.]+") 

MaxDate = StrOutput.Cast(of Match).Max(Function (x) DateTime.ParseExact(x.ToString,"dd.MM.yyyy",CultureInfo.InvariantCulture))

MaxDate is of Datetime variable

Write Line ==> MaxDate.tostring(“dd/MM/yyyy”)

Hope this helps…

Please share workflow as shared above

@Sakshi_Jain - Please find the workflow attached…
Regex_Sakshi.zip (65.7 KB)

If you run it, it will print the max date from the list…