‘2011-12-26’,‘2017-08-19’,‘2020-01-30’,‘2018-11-07’,‘2020-11-01’
I have this stirng. And I want take the freshest date only( 2020-01-30) how?
‘2011-12-26’,‘2017-08-19’,‘2020-01-30’,‘2018-11-07’,‘2020-11-01’
I have this stirng. And I want take the freshest date only( 2020-01-30) how?
@RPA3 first convert the following dates into list of DateTime then you can sort the list in descending fashion. Then the first item of the sorted list will be your recent date.
How I can do it?
‘2011-12-26’,‘2017-08-19’,‘2020-01-30’,‘2018-11-07’,‘2020-11-01’
To convert date string to date and time format use the below function
DateTime.ParseExact("2011-12-26","yyyy-MM-dd",Nothing).ToString
Use a for each activity to loop around each date and use add to collection activity to populate list(Of datetime) then use sort
I add in collection. How I can sort now?
@RPA3
Assumed you have a list of Datetime in place
Yourdatetimelist.OrderBy(function (x) x).Last()
Should Return the newest date
The freshest date not written at last, it maybe first or secon or last
Error:
Error ERROR Validation Error Compiler error(s) encountered processing expression “datesCol.OrderBy (function (x) x) .Last ()”.
Value of type ‘Date’ cannot be converted to ‘System.Collections.Generic.List(Of Date)’.
@RPA3 Can you share your xaml file? and can you tell us what is meant by Freshest Date according to you
Orderby is sorting Ascending, so we would expect oldest Date on First Position, newest on Last Position after sorting.
In Case of IT IS Not returning as expected then Debugging is recommended for further analysis
List should be of Datatype list(of Datetime)
The Datatype of the variable getting assigned by the Return of the Statement should not be a list, but from Datatype datetime
I didn’t understand. Could you send process, please?
Hello @RPA3
Try using this code
String.Split(","c).OrderBy(Function(r) cstr(r) ).last
use this code and let me know about it
Hello @RPA3
Try the below code in uipath.
Thank you for your code @vickydas.it’s working.
getClosestDate.xaml (7.7 KB)
Hello! Thank you
It filter by date, then month and only then for years.
I have:
But I need the first date - 29.01.2020
I used this: «dateCol.OrderBy (function (x) x) .Last ()».
array of string
Error: Write Line: Conversion from string “29.01.2020” to type ‘Date’ is not valid.