Var month1,month2: integer;
...
begin
 ...
  //在ado中,对sql server用
  ADoQuery1.Close;
  adoquery1.SQL.Clear;
  adoQuery1.SQL.ADD('month(销售日期)>=:t1 and month(销售日期)<=:t2');
  AdoQuery1.Parameters.ParamByName('t1').Value:=month1;
  AdoQuery1.Parameters.ParamByName('t2').Value:=month2;
  AdoQuery1.open;   //当 month1,month2取值为1到9时,正常,
  //但 month1,month2取值在10以上时,好象就不对了,是怎么回事?

解决方案 »

  1.   

    谢谢解答。
    但是用between的结果也是一样
      

  2.   

    同楼上,用delphi的函数(like endofmonth之类的函数)设置好参数.再传个sql
      

  3.   

    我这样调试通过'month(销售日期) between ' + IntToStr(month1) + ' and ' + IntToStr(销售日期)
      

  4.   

    错了'month(销售日期) between ' + IntToStr(month1) + ' and ' + IntToStr(month2)
      

  5.   

    谢谢luckyhh,按您的做法,问题解决了。