with adoquery1 do
            begin
              close;
              sql.Clear;
              sql.Add('select * from table where  left(table.rq,10)>=:bb and left(table.rq,10)<=:cc and yhxx.kczh=jzlj.kczh order by jzlj.kczh asc');
adoquery1.Parameters.ParamByName('bb').value:=formatdatetime('yyyy-mm-dd',datetimepicker1.date);
adoquery1.Parameters.ParamByName('cc').value:=formatdatetime('yyyy-mm-dd',datetimepicker2.date);
open;
first;

解决方案 »

  1.   

    sql.Add('select * from table where  left(table.rq,10)>=:bb and left(table.rq,10)<=:cc and yhxx.kczh=jzlj.kczh order by jzlj.kczh asc');
    改为sql.Add('select * from table where  left(table.rq,10)>=:bb and left(table.rq,10)<=:cc')
      

  2.   

    在表AAA中有一个字段DT,类型为DateTime。
    下面是完整的sql语句:
    'select * from AAA where DT>='''
    +DateTimeToStr(datetimepicker1.datetime)
    +''' and DT<='''+DateTimeToStr(datetimepicker2.datetime)+''''
    记住给分哦,呵呵