Dim starttime, endtime As Date
starttime = DTPicker3.Value
endtime = DTPicker4.Value
1、
select * from GG 
where CheckDate  between '" & CStr(Format(starttime, "YYYY-MM-DD HH:MM")) & "'  and  '" & CStr(Format(endtime, "YYYY-MM-DD HH:MM")) & "' 
2
select * from GG 
where CheckDate  between '" & CStr(starttime) & "'  and  '" & CStr(endtime) & "' 
3
select * from GG 
where CheckDate  between '" & starttime & "'  and  '" & endtime & "'

解决方案 »

  1.   

    但是在SQL2000的查询分析器中这么写是可以查出数据的:
    select * from GG where checkdate between '2000-02-04 14:20:00' and '2007-02-04 14:20:00';
    而且上面的三条语句调试时变量的值也是正确的。谢谢各位了!甚至调试出的SQL语句就是上面的语句
    select * from GG where checkdate between '2000-02-04 14:20:00' and '2007-02-04 14:20:00'
    但就是查询不出数据来。
      

  2.   

    你的SQL语句是不是还有其它的?