Find the maximum and minimum dates in a datatable

Hi @divyaag,

maxDate = Convert.ToDateTime(dataTable.Compute("MAX(TheDateColumnName)", null))
minDate = Convert.ToDateTime(dataTable.Compute("MIN(TheDateColumnName)", null))

Or
dataTable.AsEnumerable().Max(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString

dataTable.AsEnumerable().Min(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString

Regards,
Arivu

10 Likes