query1.SQL.Add('select * from 总览表 where 记录日期 between  '''+ datetostr(datetimepicker1.Date)+ '''  and '''+ datetostr(datetimepicker2.Date)+  '''');如果不转型SQL语句就不成功,很郁闷,转成字符型就变成查2007-1-1时把2007-1-1*的记录都查出来了.

解决方案 »

  1.   

    什么数据库?ACCESS? 还是...?
      

  2.   

    如果是ACCESS,“记录日期”字段为日期型,则:query1.SQL.Add('select * from 总览表 where 记录日期 between  CDate(' + QuoTedStr(datetostr(datetimepicker1.Date)) + ') and CDate(' + QuoTedStr(datetostr(datetimepicker2.Date)) +  ')' );
      

  3.   

    恭喜楼主已于午前自己解决此问题。http://community.csdn.net/Expert/topic/5327/5327193.xml?temp=.8400537
      

  4.   

    convet(int,convet(charvar(8),ddate,112))就行了。
      

  5.   

    SQL语句中,日期型常量,两边用 #
    如  #2005-1-1#
      

  6.   

    query1.SQL.Add('select * from 总览表 where 记录日期 between #'+ datetostr(datetimepicker1.Date)+ '# and #'+ datetostr(datetimepicker2.Date)+ '#');