keyup
答案 0 :(得分:0)
试试这个:
SELECT T.NAME AS Expr1, T.AREA AS Expr2, T.AlarmCount,
Format([T].[ITIME],"General Date") AS ITIME,
Format(T.ATIME,"General Date") AS ATIME,
Format(T.NTIME,"General Date") AS NTIME,
T.DURATION AS Expr3
FROM (SELECT DISTINCT(IWTUSER_ALARMS.NAME) AS NAME,
COUNT(*) AS AlarmCount,
IWTUSER_ALARMS.AREA AS AREA,
IWTUSER_ALARMS.ITIME AS ITIME,
IWTUSER_ALARMS.ATIME AS ATIME,
IWTUSER_ALARMS.NTIME AS NTIME,
IWTUSER_ALARMS.DUR AS DURATION
FROM IWTUSER_ALARMS
GROUP BY IWTUSER_ALARMS.NAME,
IWTUSER_ALARMS.AREA,
ITIME,
ATIME,
NTIME,
IWTUSER_ALARMS.DUR
) AS T
WHERE (((T.ITIME)>=Date()-180));
错误是由您的WHERE
子句引起的。 ITIME
已经是一个日期,因此您可以比较它而不需要格式化为字符串(格式表达式错误),然后还原为日期无效的日期,ITIME
来自临时表T
IWTUSER_ALARMS
条款中没有WHERE
。
IWTUSER_ALARMS.DUR AS DURATION
有别名DURATION
。
您的日期格式错误。试试Debug.Print Format(#6/18/2016#,"0000-00-00 00\:00\:00 ")
。这是格式化日期http://www.techonthenet.com/access/functions/date/format.php的方式。
ITIMES, ATIME and NTIME
应显示为字符串,我假设或删除格式(请参阅WHERE
子句错误)。
避免在变量和标识符中使用NAME
之类的保留关键字。希望我抓住他们所有人!