Results 1 to 5 of 5
  1. #1
    CMLS is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Posts
    2

    No activity in last 30 days

    Hello

    I'm trying to create a query to that shows only records that haven't had an entry within the last 30 days.

    Obviously it's easy to show the whole list using my current SQL...

    *************************************


    SELECT EventLog.EnquiryID, EventLog.EventDate
    FROM EventLog
    *************************************

    I'm guessing that they query will have to look at the main table [customers.EnquiryID] to compare records.

    I've been trying several things but this one is a little over my head so any help would be gratefully received.

    Thanks in advance

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Welcome to the forum!

    Assuming that you might have many records with the same EnquiryID (but different dates), I would create a query that finds the most recent eventdate for each enquiryID

    query name: qryMostRecentEvent
    SELECT EventLog.EnquiryID, Max(EventLog.EventDate) as MostRecentEventDate
    FROM EventLog
    GROUP BY EventLog.EnquiryID


    Now you can create another query that find those enquiries which have a MostRecentEventDate > 30 days from today

    SELECT qryMostRecentEvent.EnquiryID, qryMostRecentEvent.MostRecentEventDate
    FROM qryMostRecentEvent
    WHERE datediff("d",qryMostRecentEvent.MostRecentEventDat e,date())>30

  3. #3
    Join Date
    Mar 2011
    Posts
    15
    You can also use the dateAdd function, pretty much the same but it can't harm to have another solution:

    WHERE DateAdd("d", 30, qryMostRecentEvent.MostRecentEventDate) > now()
    or
    WHERE DateAdd("d", -30, now()) > qryMostRecentEvent.MostRecentEventDate

  4. #4
    CMLS is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Posts
    2

    Thank you!

    It works! Thank you, thank you, thank you. I would have never have got that by myself.

  5. #5
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome. Glad we were able to help out.

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

Similar Threads

  1. Select Dates between days and two days ago?
    By rstonehouse in forum Queries
    Replies: 4
    Last Post: 08-18-2010, 02:13 AM
  2. How can I program an "activity indicator"
    By John Southern in forum Programming
    Replies: 5
    Last Post: 06-29-2010, 07:49 AM
  3. Structured Activity
    By Logix in forum Queries
    Replies: 2
    Last Post: 06-10-2010, 06:05 AM
  4. How to Close access form after no activity
    By russ0670 in forum Forms
    Replies: 1
    Last Post: 05-17-2010, 08:17 AM
  5. less than 180 days old
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 06-04-2009, 04:29 PM

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