Array Question

OK i have an array that contains dates( lets just say 3 and here is example and format( 04/15/20, 03/27/20, and 02/10/20)) . What i’m wanting to do is loop thru that array and as i do compare them all to see which has the highest date. How would i go about this? I’d assume in some sort of “For Each” but unsure how to structure it. Thanks for any help!

@robert.miller
Welcome to the forum

Finding the highest date can be achieved within an assign. have a look here:

strDates.OrderBy(Function (s) DateTime.ParseExact(s,“MM/dd/yy”, CultureInfo.InvariantCulture)).Last()

2 Likes

I know the ParseExact has 3 arguments that it takes in, but I don’t understand the last argument “CultureInfo.InvariantCulture” - whenever I try to use this, I get the error “CultureInfo is not declared”.

My variable is called “vModifiedArr” that contains the array of 3 dates that I am trying to find the newest date.

I tried this expression: vModifiedArr.OrderBy(Function (s) DateTime.ParseExact(s, “MM/dd/yy”, CultureInfo.InvariantCulture)).Last()

@ppr

@robert.miller
ensure you have imported System.Globalization
doing this just click on imports (nearby the Variable Panel) and add the namespace System.Globalization

@ppr thanks for the reply. Now i’m getting a “string cannot be converted to 1-dimensional array uipath” Any thoughts? And thank you again for any insight.

my “assign” on the left is my array vModifiedArr

and the other side is the argument. vModifiedArr.OrderBy(Function (s) DateTime.ParseExact(s, “MM/dd/yy”, CultureInfo.InvariantCulture)).Last()

check in variable panels the correct datatype of your array variable