Results 1 to 8 of 8
  1. #1
    MFS is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235

    Only show data for past 4 hours

    Hello,
    Has been awhile since last on the forum.


    My question, which is probably an easy one but for some reason I just can't figure it out, is my Query has a 'time' column. How can I only show data from NOW to 4 hours prior?
    Can someone help?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,636
    Need the date part or will get all years. Is there also a date field? Try:

    WHERE [datefield] & " " & [timefield] BETWEEN DateAdd("h", -4, Now()) AND Now()
    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.

  3. #3
    MFS is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235
    Thanks June7,
    Yes I have a date field, aka "Date1" and my time field is "timeatPour"
    How would I write this in the criteria

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,636
    Substitute the dummy field names I used with your real field names.

    Can switch the query to SQL view and type the WHERE clause criteria. Then switch to Design view to see the result.
    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.

  5. #5
    MFS is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235
    June7, I get the following error . . .


  6. #6
    MFS is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235
    Click image for larger version. 

Name:	Untitled.jpg 
Views:	5 
Size:	186.5 KB 
ID:	15604Attached image

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,636
    WHERE clause goes after the FROM clause.

    SELECT ...
    FROM ...
    WHERE ...;
    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.

  8. #8
    MFS is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235
    Thanks June7, Now I do feel stupid!!!! Works perfectly.
    I appreciate all the help you have given me over the years.

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

Similar Threads

  1. Replies: 6
    Last Post: 11-25-2013, 10:53 AM
  2. Replies: 17
    Last Post: 11-06-2013, 05:38 PM
  3. Query for Past 12 Hours
    By esh112288 in forum Queries
    Replies: 1
    Last Post: 02-08-2013, 04:18 PM
  4. clear past data during form open
    By newaccess in forum Forms
    Replies: 1
    Last Post: 01-09-2013, 10:55 AM
  5. Show past records for same user
    By l3111 in forum Database Design
    Replies: 3
    Last Post: 03-03-2011, 10:57 AM

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