Get latest and earliest date from column

Hi @SorenB

earliestDate = dt.AsEnumerable() _
    .Select(Function(row) DateTime.ParseExact(row("Dates").ToString(), "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture)) _
    .Min().ToString("dd-MM-yyyy")
latestDate = dt.AsEnumerable() _
    .Select(Function(row) DateTime.ParseExact(row("Dates").ToString(), "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture)) _
    .Max().ToString("dd-MM-yyyy")

Regards,

1 Like