VB.NET Compute MAX/MIN/SUM in Dataset

Full screen VB.NET Topic list Since you already have the values in a DataTable you can use the Compute method to find the most recent date. [Second string parameter is a filter] Dim maxDt as Object = dt.Compute("MAX(punchdate)", "") Dim minDt as Object = dt.Compute("MIN(punchdate)", "") In your example maxDt would be the most recent entry for "John", "15-sep-2014", and minDt would be the oldest entry for "Rajesh", "01-jan-2014". NOTE: I recommend casting maxDt and minDt to a Date data type: Dim maxDt as Date = Date.Parse(dt.Compute("MAX(LAST_LOGIN_DATE)", "").ToString()) dsinvoices.Tables("xheader").Rows.Count DateTimePicker1.Value = "15/01/2015" Dim maxDt as Object = dt.Compute("MAX(punchdate)", "") Dim minDt As Object = dsinvoices.Tables("xheader").Compute("MIN(trandate)", "") Dim maxDt As Object = dsinvoices.Tables("xheader").Compute("MAX(trandate)", "") MessageBox.Show(maxDt.ToString) DateTimePicker1.Value = minDt.ToString DateTimePicker3.Value = maxDt.ToString dsinvoices.Tables("xheader").Rows.Count Copyright © 2015-19 Allied Factors Limited. All Rights Reserved.