想根据日期查询(10分)

Q

qiqini

Unregistered / Unconfirmed
GUEST, unregistred user!
我的日期字段名是usetime,我想实现根据日期查询的功能,比如输入200212,就出来
2002年12月份的记录列表
query1.SQL.Clear;
query1.SQL.add('select * from usermana');
query1.SQL.add('where usetime is not null');
if ((sender=button3)and(edit3.text<>'' ))then query1.sql.add('and usetime like''%'+edit3.text+'%'' ');
query1.Close;
query1.open;
可是那条IF语句我不会写,可以帮我看看吗?谢谢!
 
if ((sender=button3)and(edit3.text<>'' ))then
query1.SQL.add('and CONVERT(VARCHAR(6),usetime,112) ='''+edit3.text+''' ');
 
不对耶,报错!
 
报什么错?你不是用SQL数据库吗?
 
我是远程访问ORACLE数据库
 
等待高人的答案,你可以先试试自己的程式,多加点空格
query1.SQL.add('select * from usermana ');
query1.SQL.add('where usetime is not null ');
if ((sender=button3)and(edit3.text<>'' ))then
query1.sql.add('and usetime like ''%'+edit3.text+'%'' ');
 
我的日期字段名是usetime,我想实现根据日期查询的功能,比如输入200212,就出来
2002年12月份的记录列表
query1.SQL.Clear;
query1.SQL.add('select * from usermana');
query1.SQL.add('where usetime is not null');
if ((sender=button3)and(edit3.text<>'' ))then query1.sql.add('and usetime like''%'+edit3.text+'%'' ');
^^^^
不能用like要用usetime>:yourdate....');
query1.params.parambyname('yourdate').asdate:=now;
query1.open;
 
多人接受答案了。
 

Similar threads

顶部