how to find the max in a datacolumn of datetime?

francops henri picture francops henri · Nov 28, 2011 · Viewed 24.7k times · Source

I have a DataColumn of DateTime, I would like to know how I can have only the sooner date (min) and the later date (max).

Thanks

Answer

Fergara picture Fergara · Jun 11, 2012
object maxDate = dataTable.Compute("MAX(TheDateColumnName)", null);
object minDate = dataTable.Compute("MIN(TheDateColumnName)", null);