SQL语句如下:
tmpQuery.SQL.Add('select * from T_TestTask where StartTime>'''+strToDateTime(date2)+'''');其中StartTime是日期时间类型,date2是字符串类型,存储的也是时间,编译的时候报错啊。
[Error] untMain.pas(1459): Incompatible types: 'String' and 'TDateTime'
将strToDateTime去掉,编译没问题,运行就报错了。怎么处理啊。
StartTime>to_date('''+date2+''',''yyyy/mm/dd hh24:mi:ss'')
如果是access日期还要加上'#'修饰符
tmpQuery.SQL.ParamByName('StartTime').AsDatetime:=strToDateTime(date2);看下得不!
tmpQuery.SQL.ParamByName('StartTime').AsDatetime:=strToDateTime(date2);看下得不!