注册 登录
编程论坛 Delphi论坛

[求助]sql语句

guozhengbin 发布于 2006-07-31 12:02, 663 次点击
我用的是Delphi,查询数据库中的时间段的值,
如下,
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add ('select * from aaa where wdatetime='+maskedit1.text+' and '+maskedit2.text+'');
adoquery1.open;
但是没有反映,
请高手指点
5 回复
#2
baoxuelan2006-07-31 22:35
应该是查询条件有问题
#3
ysp_19842006-08-01 08:56
在某两个数值之间 应用between ...and..或> 和 < ,但对时间我不知道行否?
引号之内的SQL语句写法也不对!

[此贴子已经被作者于2006-8-1 8:58:13编辑过]

#4
xuanxuan76762006-08-01 09:25
试试
adoquery1.sql.add ('select * from aaa where wdatetime between '+maskedit1.text+' and '+maskedit2.text+'');
再检查一下你时间字段的类型
#5
wangdayong2006-08-03 17:37

V_DateB:=FormatDateTime('YYYY/MM/DD',Date_B.Date);
V_DateE:=FormatDateTime('YYYY/MM/DD',Date_E.Date);

先转换格式
条件 >= V_DateB and <=V_DateE
#6
kaifa2006-08-07 12:13
试试
adoquery1.sql.add ('select * from aaa where wdatetime >= '+#39+maskedit1.text+#39+' and wdatetime <= '+#39+maskedit2.text+39);
再检查一下你时间字段的类型是否正确
1