Finding Latest Date

Hello all, I have set of dates in the column name ‘to’ of a data-table. Out of those dates I have to point to the date which is latest, for example if I have 2 dates 12-03-2012 and 12-03-2024, then I should be able to click on 12-03-2024.

Hardik Durgam.

Hi @Hardik_Durgam ,

Check the below Expression :


The above should give you the latest date value but it will be in the form of String. We can also convert it to the Format requried once we get to know this is working for your case.

Finding_Last_Date.xlsx (9.4 KB)
Finding_latest_date.xaml (7.7 KB)

Please find the attached workflow with test input file for your requirement


Hi @varunk ,

Check this below code to get the latest date,

requiredDate(String as type) = (From r In dt Order By System.DateTime.ParseExact(r("Latest_Date").ToString.Trim,"MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture) Descending Select System.DateTime.ParseExact(r("Latest_Date").ToString.Trim,"MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture))(0).ToString("dd-MMM-yy")


Hope this might help you :slight_smile:

1 Like

Hi @Hardik_Durgam

To identify the latest date in the “to” column of a data table in UiPath, you can follow these steps:

  1. Use the “Read Range” activity to read the data from the data table and store it in a data table variable.
  2. Use the “For Each Row” activity to loop through each row in the data table.
  3. Inside the loop, use the “DateTime.ParseExact” method to convert the date string in the “to” column to a DateTime object.
  4. Compare the DateTime object with a variable that stores the latest date found so far. If the DateTime object is later than the latest date, update the variable with the new DateTime object.
  5. After the loop finishes, you will have the latest date stored in the variable. You can then use this date to perform any necessary actions, such as clicking on a date picker.

@Nitya1 your solution is great. If possible could you share the workflow ?

Hardik Durgam.