B
baoyun
Unregistered / Unconfirmed
GUEST, unregistred user!
Access关于时间查询问题,时间字符串为常量行,但是用变量代入就不行,疯掉。详细如下
T1 :='#'+DateToStr(DP1.Date)+'#';
T2 :='#'+DateToStr(DP2.Date)+'#';
sqlstr :='select * from WorkPlanTable where Date>='''+T1+''' and Date<='''+T2+''' order by Date';
报错:[Microsoft][ODBC Microsoft Access Driver] 标准表达式中数据类型不匹配。
如果写成:sqlstr :=cxstr :='select * from WorkPlanTable where Date>=''#2007-11-01#'' and Date<=''#2007-11-30#'' order by Date';
报错同上。
如果写成:sqlstr :=cxstr :='select * from WorkPlanTable where Date>=#2007-11-01# and Date<=#2007-11-30# order by Date';
就没问题。
请教高人需要变量查询时怎么写才对
T1 :='#'+DateToStr(DP1.Date)+'#';
T2 :='#'+DateToStr(DP2.Date)+'#';
sqlstr :='select * from WorkPlanTable where Date>='''+T1+''' and Date<='''+T2+''' order by Date';
报错:[Microsoft][ODBC Microsoft Access Driver] 标准表达式中数据类型不匹配。
如果写成:sqlstr :=cxstr :='select * from WorkPlanTable where Date>=''#2007-11-01#'' and Date<=''#2007-11-30#'' order by Date';
报错同上。
如果写成:sqlstr :=cxstr :='select * from WorkPlanTable where Date>=#2007-11-01# and Date<=#2007-11-30# order by Date';
就没问题。
请教高人需要变量查询时怎么写才对