How to find max value in list

I have list(of string) in which contains the folder names as dates ‘MM.dd.yy’ and i need to find the latest date from this list

@ppr @supermanPunch


Hello @Sree_Krishnan_vellinezhi

Please refer to the below post.


Try with the below steps.

  1. Create a variable as “lstDates” as List(Of DateTime) datatype
  2. Then use assign activity to convert your datetime string list to List(Of DateTime)
    lstDates= yourListStringDate.[Select](Function(x) DateTime.ParseExact(x, “MM…dd.yy”, Nothing)).ToList()
  3. You can get min date → lstDates.Min()
  4. You can get maxdate → lstDates.Max()

This will return as datetime datatype

Some sample values would be helpfully. Give a try on following:

myMaxDate | DateTime =

(From x in YourList
let m = System.Text.RegularExpressions.Regex.Match(x, "\d{2}\.\d{2}\.\d{2}")
Where m.Success
Let dp = DateTime.ParseExact(m.Value, "MM.dd.yy", System.Globalization.CultureInfo.InvariantCulture)
Order by dp.Date
Select v = dp).Last()

This is array not list @Rahul_Unnikrishnan

My actual process is i have a path in which there are several folders named with dates mm.dd.yy i need to get only the latest date folder (excluding the nondate folders)

Note:- Cant find through modified date because all folders are created same day itself)

LINQ should work for this including defensive handling of non dates. Had you tried?

Yes @ppr it worked.

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