'rq 是数据库里的一个日期字段
’我想拿名字="张三" 和日期=2004年12月的一条记录。
’我写了下面一句,出错。
'请高手办我看看
chkdate="200412"
select * from testdbf where name = "张三" and  left(str(rq),6) = '" & chkdate & "' "

解决方案 »

  1.   

    Dim chkdate As Date
    chkdate = #12/1/2004# "select * from testdbf where name = 'ÕÅÈý' and fomat(rq,'yyyy-mm') = #" & Format(chkdate, "yyyy-mm") & "#"
      

  2.   

    select * from testdbf where name='张三' and date like '200412__';
      

  3.   

    '不好意思,有乱码.Dim chkdate As Date
    chkdate = #12/1/2004# "select * from testdbf where name = '张三' and fomat(rq,'yyyy-mm') = #" & Format(chkdate, "yyyy-mm") & "#"
      

  4.   

    Select * From  testdbf Where name='张三' And Date like '2004-12%'
      

  5.   

    sqlserver  中应该是这么写吧
    "select * from testDbf where name = '张三' and left(convert(varchar(10),rq,112),6) = '200412'"
    我觉的用 convert 函数比较好
      

  6.   

    taosin() 的代碼應該是正確的!
      

  7.   

    select * from testdbf where name='张三' and rq like '200412%';
      

  8.   

    select * from xxxx where name='kkk' and year(rq)='2004' and month(rq)='12'
      

  9.   

    select * from xxxx where name='kkk' and year(rq)='2004' and month(rq)='12'