Pick the latest date in datatable

i have a datatable like this in some cases… in some cases there is no datatable …
if i found the datatable … i need to pick the latest date in the column-2 that is date and time…
and i want to pick the column-2 text… how can i do this

is there any approach


dt.AsEnumerable().OrderByDescending(Function(row) row.Field(Of DateTime)(“Column-2”)).First()

what is the datatype i have to put

in general we would try:

  • datascraping to the webtable and extract all data
  • using a LINQ, DataTable.Compute… for getting the latetest date

It looks that the datestring contains an @. Here we have to decide which string to dateTime parsing approach will be the preferred one e.g. DateTime.ParseExact

this like iam getting when i scrape the datatable using datascrapping


Datarow is the datatype

if i use datarow as a datatype im getting this error

dateLatest | String =

YourDataTable.AsEnumerable.OrderBy(Function (x) DateTime.ParseExact(x("Column-2").toString.Trim,"MM/dd/yyyy @ h:mmtt",System.Globalization.CultureInfo.InvariantCulture)).Last()


  • Use the “Read Range” activity to read your data into a DataTable variable. Let’s call it “dtData.”

Find the Latest Date

  • Add a “For Each Row” activity to loop through each row in the DataTable.
  • Inside the loop, use an If activity to compare the date in the current row with the latest date found so far.
  • You can use the DateTime.ParseExact method to convert the date from string format to a DateTime object for proper comparison.

DateTime.ParseExact(row("DateColumn").ToString(), "your_date_format_here", CultureInfo.InvariantCulture) > latestDate

  • If the date in the current row is greater than the latest date found so far, update the “latestDate” variable with the value from the current row.

Output the Latest Date

  • After the loop, the “latestDate” variable will hold the latest date from the DataTable.

Hope it helps!!

getting this error

corrected the code above due the @ was ommited


dt.AsEnumerable().OrderByDescending(Function(row) DateTime.ParseExact(row.Field(Of String)(“Column-2”), “your_date_format_here”, CultureInfo.InvariantCulture)).First()
Try using this

Hi @Nikhil_Katta

  1. Use this in Assign activity:
latestDateRow= dtData.AsEnumerable().OrderByDescending(Function(row) DateTime.ParseExact(row("Column-2").ToString, "MM/dd/yyyy HH:mm tt", System.Globalization.CultureInfo.InvariantCulture)).First

latestDataRow Datatype: System.Data.DataRow

  1. Use an If condition and give below condition:
latestDateRow isnot Nothing

Datatype of latestDate: System.DateTime
3. Print latestDate in Message Box

Please find the below workflow file:
Sequence26.xaml (9.8 KB)

Hope it works!!

latestDateRow isnot Nothing

not working

Can you show the error @Nikhil_Katta




Try this syntax in assign activity under If condition:

latestDateRow isnot Nothing
           latestDate=DateTime.ParseExact(latestDateRow("Column-2").ToString,"MM/dd/yyyy @ HH:mm tt",System.Globalization.CultureInfo.InvariantCulture)

latestDate Datatype: System.DateTime

Updated xaml has been uploaded
Sequence26.xaml (9.9 KB)


Sequence26 (1).xaml (9.8 KB)
US_Holiday_list (1).xlsx (8.4 KB)

can u plz check… i just atatched the doc


I have uploaded the updated xaml with your excel sheet.
Sequence26.xaml (9.9 KB)



This is my datatable after extracting… you can see here my latest date is 01/01/2022 @ 1:23AM

But why we are getting the datewrong