老大怎么选择数据库中一段时间数据呀?
数据库里头的时间列设置为:YYYY-MM-DD-HH
[C#] 纯文本查看 复制代码 //选择的日期
string year = this.year.SelectedItem.Text.ToString();
string month = this.month.SelectedItem.Text.ToString();
string day = this.day.SelectedItem.Text.ToString();
string hour = this.hour.SelectedItem.Text.ToString();
string begindate = year + "-" + month + "-" + day + "-"+ hour;
string enddate = "2014-9-5-16";
string searchtime="select *from TimeTest whert AccountTime between'"+begindate+"'and'"+enddate+"'";//【这句百度了,还是不对。怎么改呀?】
DataTable dt = db.reDt(searchtime);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
谢谢老大!
|