2.
select * from yourtable where addtime between '2005-01'+'-01' and dateadd(month,1,'2005-01'+'-01')

解决方案 »

  1.   

    select * from tableA where CONVERT(varchar(7), add_time, 120)='2005-01'
      

  2.   

    首先你可以用getdate()函数来记下当时的日期

    你可以用like的方法把条件显示出来
    e.g 
    select * from 
    where time like '2005-01%'
      

  3.   

    select * from yourtable where addtime between '2005-01'+'-01' and dateadd(month,1,'2005-01'+'-01')--0.0000001
      

  4.   

    1、
    SELECT 
        CONVERT(varchar(7), add_time, 120) as ADDTIME,
        count(*)
    FROM 
        tableA
    GROUP BY
        CONVERT(varchar(7), add_time, 120) 2、
    SELECT * FROM tableA where CONVERT(varchar(7), add_time, 120) = '2005-01'
      

  5.   

    我才写了一个只查附合年份的,加查月份只需相应加上就行
    SELECT mtb.*  
    from  CPMS_ScientificResearchLayout mtb 
    WHERE CAST(mtb.SctRscLatTime AS varchar(30)) LIKE '%2005%'
      

  6.   

    sqlstr = "select * from tableA where convert(char(7),add_time,120)='" & DropDownList.Text & "'"