Hi,
How to do get Min / Max Date value from DataTable in ASP.Net?
My code below, but return is
System.Data.DataRow[]
System.Data.DataRow[]
c#
private DataTable Rss()
{
DataTable dt = new DataTable();
DataSet ds = new DataSet();
using (MySqlConnection myConnectionString =
new MySqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString))
{
using (MySqlCommand cmd =
new MySqlCommand("sp_tb_s", myConnectionString))
{
cmd.CommandTimeout = 2147483;
cmd.Connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Clear();
adapter.Fill(ds);
if (ds.Tables.Count > 0)
{
dt = ds.Tables[0];
var maxRow = dt.Select("_Date = MAX(_Date)").ToString();
var minRow = dt.Select("_Date = MIN(_Date)").ToString();
Response.Write(maxRow + "<br />" + minRow + "<br />");
}
}
}
return dt;
}