LinQ query help regarding duplicates

u will get a datatable with duplicates removed. post which you can use a simple linqu to get the results based on effective date.

Your LINQ query seems mostly correct. However, there are a few adjustments needed

  1. You need to specify the date formats for parsing correctly.
  2. “DateTime.ParseExact” method requires an array of formats, not just a single format string.

So the Query goes like this

var result = (from row in AdditionsReportDT.AsEnumerable()
group row by row.Field(“Associate ID”) into grp
let maxDateRow = grp.OrderByDescending(r => DateTime.ParseExact(r.Field(“Effective Date”), new string { “MM-dd-yyyy”, “MM/dd/yyyy” }, CultureInfo.InvariantCulture)).First()
select maxDateRow).CopyToDataTable();