日期:2014-05-18  浏览次数:20614 次

脑子晕了,一个SQL语句问题,请大家帮忙修正!
一个SQL语句问题,请大家帮忙修正!
SqlSt:='select * from DutyTask where MinutesBetween(strtodatetime(Tnow),strtodatetime(时间标识))< 15';

DutyTask:表名
MinutesBetween,strtodatetime均为函数
时间标识:DutyTask表中的字段名
Tnow:变量

针对这个语句,我来回调试,都通过不了,肯定表述有问题,自己又找不出来,请各位帮忙了!



------解决方案--------------------
MinutesBetween,strtodatetime都是delphi 的函数,放到sql里不行的

试试
SqlSt:='select * from DutyTask where datetiff(mi, cast(Tnow as datetime),时间标识)<15';
------解决方案--------------------
试试下面的

Delphi(Pascal) code

SqlSt:='select * from DutyTask where '+
   ' datediff(mi, '''+strtodatetime(Tnow)+''', 时间标识) < 15';