Results 1 to 2 of 2
  1. #1
    rlove is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    1

    Access query from SQL Database

    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

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Why isn't it working - error message, wrong results, nothing?

    Your IIf expression is missing a comma in front of DateAdd.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access Web Database - Search Query Combatibiity
    By AndreasPanayiotou in forum Queries
    Replies: 0
    Last Post: 09-18-2012, 10:37 AM
  2. Replies: 2
    Last Post: 07-03-2012, 11:46 PM
  3. Replies: 0
    Last Post: 03-01-2011, 10:47 AM
  4. Migration from Access 2003 database to Access 2007 database.
    By cyclus2 in forum Import/Export Data
    Replies: 1
    Last Post: 09-10-2010, 11:43 AM
  5. Replies: 3
    Last Post: 04-05-2006, 04:17 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums