adoquery4.Close;
adoquery4.sql.clear;
adoquery4.SQL.Add('SELECT xiaoshou_id,ku_name, Sum(shuliang*lingshoujia) AS 111,xinghao,shangpinming,xiaoshou_date FROM xiaoshoumingxi');
adoquery4.SQL.add('where year(xiaoshou_date)=:xiaoshou_year and month(xiaoshou_date)=:xiaoshou_month');
adoquery4.SQL.Add('GROUP BY xiaoshou_id,ku_name,xinghao,shangpinming,xiaoshou_date');
adoquery4.Parameters[0].Value:=formatdatetim('yyyy',datetimepicker1.Date);
adoquery4.Parameters[1].Value:=formatdatetime('MM',datetimepicker1.Date);adoquery4.ExecSQL;
adoquery4.Open;
adoquery4.sql.clear;
adoquery4.SQL.Add('SELECT xiaoshou_id,ku_name, Sum(shuliang*lingshoujia) AS 111,xinghao,shangpinming,xiaoshou_date FROM xiaoshoumingxi');
adoquery4.SQL.add('where year(xiaoshou_date)=:xiaoshou_year and month(xiaoshou_date)=:xiaoshou_month');
adoquery4.SQL.Add('GROUP BY xiaoshou_id,ku_name,xinghao,shangpinming,xiaoshou_date');
adoquery4.Parameters[0].Value:=formatdatetim('yyyy',datetimepicker1.Date);
adoquery4.Parameters[1].Value:=formatdatetime('MM',datetimepicker1.Date);adoquery4.ExecSQL;
adoquery4.Open;
adoquery4.Open;
-------------------------
???为什么这么写
只要adoquery4.Open;'where year(xiaoshou_date)=:xiaoshou_year and month(xiaoshou_date)=:xiaoshou_month');
--------------------------------------------------
ACCESS好象不支持直接在里面写YEAR()和MONTH()函数吧
adoquery4.Parameters[1].Value:=formatdatetime('MM',datetimepicker1.Date);的值是03,就是3月份,他是03
但数据库里是3怎么解决,数据库里是日期字段,他的格式是2004-3-16,不是2004-03-16
去掉一个"M"不就可以了.