Select the value that match with to the most recent date


I just resolved an issue thanks to @ppr
I have a data table with dates and prices (4rows)
First, I have to find wich one of the fourth is the most recent date and then collect the price from the column Price.

Thanks to @ppr he found me a way to select the most recent date. But I have an other issue : How to extract the Price link to this date.
Can anyone help me out please ?

Thank you !


You can try as below

Price = Datatable.Select("[ColumnName1]=‘text’").ElementAt(0)(“ColumnName”).ToString

Hope this helps


Thank you for your answer but it’s not working.
I have the most recent date store in a string variable.
So I think (but i might be wrong) that in your formula, the ‘text’ is my string variable. But when I replace ‘text’ by my string variable.
I have an error message saying that I cannot convert string to int.


Can you share your datatable output, so that we can help


Sure. My dt_output is like following
16.02.2019, 1.45
23.12.2020, 2.36
12.07.2018, 2.32
12.02.2011, 1.36

Then I have store into a string variable (str_RecentDate) the most recent date.
So now I need to collect the price link to the most recent date (so link to my str_RecentDate).

I hope it is clear.

mabye the flow can be adopted to following:

leftside: drResult (DataType: DataRow)
right side:

dt_DatePv.AsEnumerable.OrderBy(Function ( r ) DateTime.ParseExact(r(0).toString.Trim, “dd.MM.yyyy”, System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)).Last()

so you can retrieve Price, date e.g. by following or doing some datatype conversions

1 Like

Thank you again @ppr :slightly_smiling_face:

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