数据库中有一列datetime,为时间日期,如“2011-10-13 11:00:00”,数据量很多要在C#窗体中combobox控件中按年、月、日分开来查询请问怎么写语句?

解决方案 »

  1.   

    select * from table where year(date)=@year and month(date)=@month and day(date)=@day;int year=convert.toint32(cboYear.selectedvalue);
    int month=convert.toint32(cboMonth.selectedvalue);
    int day=convert.toint32(cboDay.selectedvalue);把 year,month,day 参数传给select即可
      

  2.   

    datetime不是有day,month和year吗?
    取出来->datetime X->X.day,X.month,X.year
    好像是 记不清了
      

  3.   

    我没明白这是要把数据库的数据查询出来以后拆开放在3个combobox中,还是有3个combobox,分别从里面去出年月日再到数据库中查询,到底要实现哪个