现在我数据库里面有个知道为日期类型:2009-08-08 00:00:00
  我现在要查询8月份的所有字段,请问我的SQL语句该如何写?

解决方案 »

  1.   

    select * from table1
    where Date >= CONVERT(DATETIME, '2009-08-01 00:00:00')) and Date<=CONVERT(DATETIME, '2009-08-31 00:00:00')) 
      

  2.   

    select * from table1
    where DATEPART(Month, Date) = 8
      

  3.   

    month(字段名)可以获取到月份
    select * from table where month(thedate)=8 and year(thedate)=2009
      

  4.   

    搂上的正确,在数据库中,
    month:月
    year:年
    day;日期select * from yourtable where month(fieldname)=9
      

  5.   

    select * from 表 where convert(varchar(7),字段,120)='2009-08'