在表中,我将一个用来存放时间的字段设置成了string类型,但是现在我要检索一个时间段内的数据,我在query控件中的sql语句是这样写的
select * from talbe1 where strtodate(riqi) between date1 and date2
但是delphi告诉我“capablity not supported”
我该怎么做呢,请高手指导,一定给分。

解决方案 »

  1.   

    select * from table1 where date1>date2如果你的时间是用DateTimetoStr(now)函数的来的,是可以比较大小的.
      

  2.   

    SQL := 'select * from table1 where '+ DateTimeToStr(riqi) + ' between date1 and date2';
      

  3.   

    select * from table1 where date1>date2
    如果你的日期字符串是DateTimeToStr(now)得到的,就可以比较
      

  4.   

    up ,
    或者,你可以分开写这个sql语句,这样看起来比较清楚,注意加号和引号的使用
      

  5.   

    sql.Add('select * from 进货表 where 进货日期>='+''''+formatdatetime('yyyy-mm-dd hh:mm:ss',datetimepicker1.datetime)+''''+' and 进货日期<='+''''+formatdatetime('yyyy-mm-dd hh:mm:ss',datetimepicker2.datetime)+'''');