SQL="select * from isa_data where date0=:time0";
frmMain->Query1->ParamByName("time0")->Value=keyword;
用上面的查时间,怎么查不出结果?
如时间为:10:01:01在数据表里显示正常,可就是查不出来?
我将time字段转换为alpha字段,显示为10:01:01 AM
但在time类型时,为10:01:01,这是为什么?
怎么查询呀????????????
复见:http://expert.csdn.net/Expert/topic/1698/1698534.xml?temp=.2824976
你在
SQL="select * from isa_data where date0=:time0";
frmMain->Query1->ParamByName("time0")->Value=keyword;
中的keyword你用FormatDateTime()函数先格式化一下看看,如果你的date0字段中保存的是日期与时间的话,你需要用到函数SUBSTRING来取其中的部分进行比较
所以sql语句应该如下的形式:
select * from 表名 where substring(date0,8,8) = :time0"
frmMain->Query1->ParamByName("time0")->Value= FormatDateTime("hh:nn:ss",时间);
试试看,不保证正确性!
SQL="select * from isa_data where date0=:time0";
frmMain->Query1->ParamByName("time0")->Value=keyword;
你看一看keyword什么类型?是什么?;
如果date0是Time类型,keyword也应该是Time类型。
keyword如果是字符型用StrToTime转换。
ftTime
你的time0是什么类型?
Query1->Params->CreateParam(ftTime,"time0",ptOutput);