把日期作为查询条件的方法

来源:互联网 发布:上海天盾数据恢复中心 编辑:程序博客网 时间:2024/06/10 02:06

 string start = this.txt_beginDate.Text;
            string end = this.txt_endDate.Text;
            DateTime start1 = Convert.ToDateTime(txt_beginDate.Text);//
            DateTime end1 = Convert.ToDateTime(txt_endDate.Text);
            if (start1 > end1)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "84", "alert('起始日期不能晚于结束日期');", true);
                return  false;
            }else

          {

1.) _filter += " and " + CAR_VIEW_车辆当前电瓶情况.COL_到期日期 + " between to_date('" + start + "','yyyy-MM-dd')" +

"and to_date('" + end + "','yyyy-MM-dd')";

 

2.) filter += " and " + CAR_VIEW_加油卡充值明细.COL_充值时间 + ">=to_date('" + start + "','yyyy-MM-dd') and " + CAR_VIEW_加油卡充值明细.COL_充值时间 + " <=to_date('" + end + "','yyyy-MM-dd')";

           }