我想比较从数据库中选择的日期(EndDate 中的每个条目)并将它们与今天的日期进行比较。有没有办法以编程方式做到这一点?就像提取日期并单独比较它们?我需要这个,因为我需要更新表格的状态。
string username;
username = HttpContext.Current.User.Identity.Name;
string date = DateTime.Now.ToString("MM/dd/yyyy");
txtDate.Text = date;
SqlConnection conn1 =
new SqlConnection("Data Source=mydatasource\\sqlexpress;"
+ "Initial Catalog = Suite2; Integrated Security =SSPI");
SqlDataAdapter adapter;
string end;
end = "SELECT EndDate FROM Table_Message WHERE username = '" + username + "'";
adapter = new SqlDataAdapter(end, conn1);
conn1.Open();
DataSet ds = new DataSet();
adapter.Fill(ds);
//Execute the sql command
GridView2.DataSource = ds;
GridView2.DataBind();
conn1.Close();