sql.text:='INSERT INTO xzhf ( encode, lrsj ) SELECT encode, lrsj FROM [select encode, lrsj from dd where lrsj=:tt union select encode ,last_medi from arch where last_medi=:tt ]. AS ex;' ;
adoquery1.Parameters.ParamByName('tt').Value :=formatdatetime('yyyy-mm-dd',datetimepicker1.DateTime );adoquery1.ExecSQL ;不动态附值的话,
比如 在sql.text 中写入时间#1998-8-10#可以运行,可是动态的话去没有结果为什么。
adoquery1.Parameters.ParamByName('tt').Value :=formatdatetime('yyyy-mm-dd',datetimepicker1.DateTime );adoquery1.ExecSQL ;不动态附值的话,
比如 在sql.text 中写入时间#1998-8-10#可以运行,可是动态的话去没有结果为什么。
改为datetimepicker1.Date你呢
比如:
1、带时间的DateTime
strSQL = 'select * from TableName where [日期时间字段]=''' + FormatDateTime('yyyy-mm-dd hh:mm:ss') + '''';
2、不带时间的DateTime
strSQL = 'select * from TableName where [日期时间字段]=#' + FormatDateTime('yyyy-mm-dd hh:mm:ss') + '#';还可以直接把时间日期查询出来后,转换为字符串,然后就是对字符串进行比较也可以,具体的access转换函数是用FormatSELECT Format(VoucherDate,'yyyy-mm-dd') FROM S_Sale_M;
SELECT Format(VoucherDate,'yyyy-mm-dd hh:mm:ss') FROM S_Sale_M;这样就不要担心是用#还是用'
我认为应先建立一个字符串变量在其内存储时间格式的字符串,再将该变量带入Sql.text中使用。