My input data table is
ID. Date
-
12/31/2020
-
12/31/2021
-
12/31/2023
-
12/31/2022
Here the highest date is 12/31/2023
I should get the output as 12/31/2023 and its corresponding folder id
My input data table is
ID. Date
12/31/2020
12/31/2021
12/31/2023
12/31/2022
Here the highest date is 12/31/2023
I should get the output as 12/31/2023 and its corresponding folder id
use sort datatable on date column and then first row will contain the info you need
cheers
Hi @sruthesanju
Build Data Table
Output->inputDataTable
=> Use below syntax in Assign:
Output = (From row In inputDataTable.AsEnumerable()
Let dateValue = DateTime.ParseExact(row("Date").ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")
Order By dateValue Descending
Select New With {
.Date = dateValue,
.ID = Convert.ToInt32(row("ID"))
}).FirstOrDefault()
Output
is of DataType System.Object.
Regards
Hey @sruthesanju
try this:
MyRow (datarow) = (From row In YourDataTable.AsEnumerable() Order By DateTime.ParseExact(row("Date").ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) Descending Select row).First()
to get values:
DateTime.ParseExact(MyRow("Date").ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Convert.ToInt32(latestRow("ID")