string sql="select endtime from item";
...
...
while(dr.Read())
{
DateTime endd=(DateTime)dr[0];
if(???)
{
...
}
}
我的IF里面应该怎么写判断从数据库读取的时间是否大于当前日期??

解决方案 »

  1.   

    if(DateTime.Parse(endd).ToShortDateString())>System.DateTime.Now.ToShortDateString())
      

  2.   

    //开始日期必须早于结束时期,开始日期必须晚于当前日期
                if(this.UcEffectDateBeginTime.GetDate()<=DateTime.Now )
                {
                    Response.Write("<script>alert('开始日期不能小于今天的日期!');</script>");
                    throw new Exception("开始日期不能早于今天日期");
                }
                //判断开始日期是否晚于截止日期
                if (this.UcEffectDateBeginTime.GetDate() >= this.UcEffectDateEndTime.GetDate())
                {
                    Response.Write("<script>alert('开始日期不能晚于截止日期!');</script>");
                    throw new Exception("开始日期不能晚于截止日期");
                }