select 
YMD
from
FM
where 
year(YMD)=1999  and month(YMD)=9或者用convert函数转换一下,用like就行了

解决方案 »

  1.   

    select YMD
    from
    FM
    where convert(varchar(7),YMD,120)>'1999-09' and convert(varchar(7),YMD,120)<'1999-09'
      

  2.   

    測試:select getdate()  
    --返回 2004-04-07 14:34:20.853select convert(varchar(10),getdate(),120)
    --返回 2004-04-07select convert(varchar(7),getdate(),120)
    --返回 2004-04
      

  3.   

    select YMD from FM
    where year(YMD) + month(YMD) > '19999' and
          year(YMD) + month(YMD) < '20004'
    利用year,month函数获取拼接的字符串,然后与需要的值比较大小。
      

  4.   

    也可用二樓的方法,使用 year()與month()函數,
    還可 datediff()函數進行月比較。
      

  5.   

    select YMD
    from
    FM
    where convert(varchar(7),YMD,120)>'1999-09' and convert(varchar(7),YMD,120)<'1999-09'
      

  6.   

    select YMD
    from
    FM
    where datediff(month,YMD,'1999/09/09')
      

  7.   

    select YMD
    from
    FM
    where datediff(month,YMD,'1999/09/09')=0
      

  8.   

    --得到1999年9月的数据
    select ymd from fm where datediff(month,ymd,'1999/9/1')=0--得到1999年9月及以前的数据
    select ymd from fm where datediff(month,ymd,'1999/9/1')>=0--得到1999年9月及以后的数据
    select ymd from fm where datediff(month,ymd,'1999/9/1')<=0
      

  9.   

    create       function datetoint (@日期 datetime)
    returns int
    as
    begin
    return year(@日期)*10000 + month(@日期)*100 + day(@日期)
    endgoselect 
    YMD
    from
    FM
    where 
    (select dbo.datetoint(YMD))>'19990909' and (select dbo.datetoint(YMD))<'19990909'