Results 1 to 6 of 6
  1. #1
    edmscan is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    168

    Retrieve records for previous 2880 minutes

    I would like to retrieve records for the previous 2880 minutes from when the query is executed. The data is stored as .. 2014-09-06 12:55:30 AM

    There will be no other criteria .. don't care about days of week or anything else .. just need records fitting this criteria.

    I thought it was simple .. but I cannot get it.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Perhaps you could apply some criteria to your query. Something like:
    >=DateAdd ( "n", -2880, Date())
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    What have you tried? What happened - error message, wrong results, nothing?

    Would any record have date/time later than the current date/time?

    You should understand that values in a date/time field not stored as you show. That is how the data can be formatted but date value is actually stored as a long integer number.

    Assuming the date is stored in a date/time type field, try:

    SELECT * FROM table WHERE [Date field]>DateAdd("n",-2880,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.

  4. #4
    edmscan is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    168
    It works perfectly ... thanks

    I used DateAdd('n',Now()-2880,Now())

    Oh .. and yes I should have said displayed or formatted as bla bla.

    The reason .. I used 2880 min cause I thought that would alleviate any issues with the date .. as 2880 min is 48 hours. This may change depending on my mood that day .. so by minutes was just better than 2 days.
    I would have to test if that would give me the same results.

    Actually .. either way gives me the exact same records. I will go with minutes.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Why does the expression show Now()-2880?
    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.

  6. #6
    edmscan is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    168
    That is what I tried before .. doesn't work. Your version was correct .. mine, was wrong of course. And I learned something once again. That is never a bad thing.

    So yes .. to clarify this is the right way .. SELECT * FROM table WHERE [Date field]>DateAdd("n",-2880,Now());

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

Similar Threads

  1. Replies: 1
    Last Post: 03-17-2014, 12:26 PM
  2. Replies: 4
    Last Post: 06-12-2013, 10:20 AM
  3. Replies: 3
    Last Post: 09-01-2011, 11:07 PM
  4. Retrieve group records based on max value
    By wireless in forum Access
    Replies: 7
    Last Post: 02-03-2011, 03:30 PM
  5. Retrieve similar records
    By dodell in forum Queries
    Replies: 3
    Last Post: 03-31-2010, 11:48 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