I have an Access Database that queries TagNames from an SQL DB(dbo) and puts them in a new access table(Consolidate). The query adds a field(Time) which looks at the EventTime of the item in the SQL Database. As of now the query is a 12 hour query finding items that occurred in the SQL DB from the previous 12 hours, ie (Criteria: >Dateadd("h", -12, Now()).
I am trying to change from a 12 hour history to a dayshift and night shift query. This would be 6am-6pm and 6pm-6am. So, I am creating another field(Expr1) where, Expr1: IIf((DatePart("h",Now())>=0) And (DatePart("h",Now())<=6)DateAdd("d",-1,Now()),Day(Now())). The criteria is: >=TimeSerial(6,0,0) And <=TimeSerial(18,0,0) This query should cover the dayshifts history when the nightshift runs the query. If the system time is greater than midnight and less than 6am use the previous days criteria, else use todays criteria. Am I heading in the right direction? it is not working properly. Thanks for any input