SQL日期拼接问题
rs.Open "select *, count(id) as A2_01 from [inf] where datediff(d,'"&year(dateadd("m",-1,year(date)&"-"&month(date)))&"-"&month(dateadd("m",-1,year(date)&"-"&month(date)))&"-24""','"&year(addtime) & "-" & right("0"&month(addtime),2) & "-" & right("0"&day(addtime),2)&"')<0",conn,1,1
选出上个月24号以后提交(ADDTIME)的信息,总是通不过
[解决办法]
sql="SELECT *, count(id) as A2_01 from [inf] datediff('d',addtime,'"&dateadd("m",-1,year(date)&"-"&month(date)&"-24")&"')>0"
[解决办法]
你用了select *又用了聚合函数count,当然通不过了。
选出上个月24号以后的直接用>号就可以了,没必须搞那么麻烦。
SELECT * FROM [INF] WHERE dateAdd(d,0,[date])>'2012-12-24'