with adrqMeterData do
try
SQL.Text := 'select * from where todaytime between '
+ ':startdayvalue and :enddayvalue';
Parameters.ParamByName('startdayvalue').Value := dtpStartDate.Date;
Parameters.ParamByName('enddayvalue').Value := dtpEndDate.Date;
ExecSQL;
except
end;
todaytime 是一个datatime字段,
这是一个日期比较查询语句,但是F9的时候出错,提示在关健字where边上有语法错误,我知道这种写法有点问题,但是不知道怎么修改。
try
SQL.Text := 'select * from where todaytime between '
+ ':startdayvalue and :enddayvalue';
Parameters.ParamByName('startdayvalue').Value := dtpStartDate.Date;
Parameters.ParamByName('enddayvalue').Value := dtpEndDate.Date;
ExecSQL;
except
end;
todaytime 是一个datatime字段,
这是一个日期比较查询语句,但是F9的时候出错,提示在关健字where边上有语法错误,我知道这种写法有点问题,但是不知道怎么修改。
select * from 表名字 where todaytime between
Parameters.ParamByName('startdayvalue').Value := FormatDateTime('yyyy-mm-dd 00:00:00', dtpStartDate.Date);
Parameters.ParamByName('enddayvalue').Value := FormatDateTime('yyyy-mm-dd 24:00:00', dtpEndDate.Date);
但是F9出错,提示:应用程序在当前操作使用了错误类型值:(
Parameters.ParamByName('enddayvalue').Value := FormatDateTime('yyyy-mm-dd 23:59:59', dtpEndDate.Date);
Parameters.ParamByName('startdayvalue').Value := strtodate(FormatDateTime('yyyy-mm-dd 00:00:00', dtpStartDate.Date));
Parameters.ParamByName('enddayvalue').Value := strtodate(FormatDateTime('yyyy-mm-dd 23:59:59', dtpEndDate.Date));
F9的结果提示:'2009-01-06 00:00:00' is not a valid date
Parameters.ParamByName('startdayvalue').Value := StrToDateTime(FormatDateTime('yyyy-mm-dd 00:00:00', dtpStartDate.Date));
Parameters.ParamByName('enddayvalue').Value := StrToDateTime(FormatDateTime('yyyy-mm-dd 23:59:59', dtpEndDate.Date));