sql="select * from 表 where datediff(month,日期字段,'" & combobox1 & "-" & combobox2 & "-1')"rs.open sql,conn

解决方案 »

  1.   

    我把上面的写为
    With adoQuery1 do
    begin
     SQL.Clear;
     sql.add('select * from 休假表 where datediff(month,假期时间至,'"& combobox1&"-"&combobox2&"-1')');
    open;
    end;
    可是老大,还是不行啊,编译都不能通过。
      

  2.   

    你用的delphi对吧?strSQL:='select * from 休假表 where datediff(month,假期时间至,'''+combobox1.Text+'-'+combobox2.Text+'-1'')';
      

  3.   

    sql.add('select * from 休假表 where datediff(month,假期时间至,'"& combobox1&"-"&combobox2&"-1')');
    改成:
    sql.add('select * from 休假表 where  convert(varchar,'&combobox1&combobox2&01',102)=假期时间至''')