我收到一条错误说"溢出"在我尝试使用CDate时在MS Access查询中

时间:2016-06-16 19:16:40

标签: sql ms-access

SELECT DISTINCT IWTUSER_ALARMS.NAME, IWTUSER_ALARMS.AID, IWTUSER_ALARMS.DUR, 
   Int(CInt([DUR])/86400) AS DAYS, Int((CInt([DUR]) Mod 86400)/3600) AS HOURS, 
   Int(((CInt([DUR]) Mod 86400) Mod 3600)/360) AS MINUTES, 
   Int((((CInt([DUR]) Mod 86400) Mod 3600) Mod 360)/60) AS SECONDS
FROM IWTUSER_ALARMS
   WHERE (((CDate(Format([IWTUSER_ALARMS].[ITIME],"0000-00-00 00\:00\:00 ")))>=Date()-10))
GROUP BY IWTUSER_ALARMS.NAME, IWTUSER_ALARMS.AID, IWTUSER_ALARMS.DUR, 
   CInt([DUR])/86400, CInt([DUR]) Mod 86400, (CInt([DUR]) Mod 86400) Mod 3600, 
   ((CInt([DUR]) Mod 86400) Mod 3600) Mod 360
ORDER BY IWTUSER_ALARMS.DUR DESC;

1 个答案:

答案 0 :(得分:0)

经过这么多试验和错误以及从不同来源收集了一些信息后,我能够解决这个问题 - 以下是工作代码。

SELECT T.ID, T.NAME, ACOUNT AS AlarmCOUNT

FROM(

SELECT DISTINCT(IWTUSER_ALARMS.NAME)AS NAME,COUNT(IWTUSER_ALARMS.NAME)AS ACOUNT,IWTUSER_ALARMS.AID AS ID

FROM IWTUSER_ALARMS

WHERE (((CDate(Format([IWTUSER_ALARMS].[ITIME],"0000-00-00 00\:00\:00 ")))>=Date()-1))

GROUP BY IWTUSER_ALARMS.NAME,IWTUSER_ALARMS.AID

)AS T. ORDER BY T.NAME DESC;