简体   繁体   中英

I am getting an error saying “Overflow” in MS Access query when I try to use CDate

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;

After so many trial and error and gathering several information from different sources I was able to solve this problem - Here is the working code below.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM