Maximum date

Hi All,

How can i get the maximum date from the data table ?i don’t want to use any loop .
Suggest me any query?

1 Like

Try this

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

Reference link : Find the maximum and minimum dates in a datatable

5 Likes

Thank u for the quick reply

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