表结构(number是自增列)
number  datetime     aa     bb     cc
1       2005-9-8     aaa    aaa    aaa
2       2004-9-8     bbb    bbb    bbb
3       2005-11-8    ccc    ccc    ccc
4       2005-9-14    ddd    ddd    ddd如果我要知道2005年的9月的数据,请问怎么写?

解决方案 »

  1.   

    select * from 表 
    where [datatime]>='2005-09-01' and
          [datatime]<='2005-09-30'
      

  2.   

    select * from table where [datetime] between '2005-9-1' and '2005-9-30'
      

  3.   

    select * from table where [datetime] between '2005-09-01' and '2005-09-30'
      

  4.   

    现在年份和月份是根据控件来进行的
    年份用numericUpDown1控件来选取
    月份用comboBox1来选取
    请问又改怎么写呢?
      

  5.   

    select * from 表 where month(datetime)=9
      

  6.   

    如果是2006年的6月份是不是这样写,给我点意见
    select * from 表 where month(datetime)=9 and year(datetime)=2005
      

  7.   

    select * from table where [datetime] between '2006-6-1' and '2006-6-30'
      

  8.   

    现在年份和月份是根据控件来进行的
    年份用numericUpDown1控件来选取
    月份用comboBox1来选取
    是不是这样写
    select * from table where month(datetime)='"+numericUpDown1.value+"' and year(datetime='"+comboBox1.Text+"')
      

  9.   

    现在年份和月份是根据控件来进行的
    年份用numericUpDown1控件来选取
    月份用comboBox1来选取
    是不是这样写
    select * from table where month(datetime)='"+numericUpDown1.value+"' and year(datetime)='"+comboBox1.Text+"'
    是不是这样?
      

  10.   

    select * from 表 where cast(substring(datatime,6,1) as int)=9
      

  11.   

    select * from table where month(datetime)='"+numericUpDown1.value+"' and year(datetime)='"+comboBox1.Text+"'
    应该改成这样:
    select * from table where month(datetime)='"+numericUpDown1.SelectedValue.ToString()+"' and year(datetime)='"+comboBox1.SelectedValue.ToString()+"'