当前位置: 代码迷 >> Sql Server >> 脑子晕了,一个SQL语句有关问题,请大家帮忙修正
  详细解决方案

脑子晕了,一个SQL语句有关问题,请大家帮忙修正

热度:33   发布时间:2016-04-27 12:22:15.0
脑子晕了,一个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';
  相关解决方案