Results 1 to 2 of 2
  1. #1
    dslatten is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    5

    Query expiration dates within specific date ranges

    So I have a database where employees are entered along with 3 specific credentials and their expiration dates. When an employee has any of the three credentials expired they are marked as "Inactive". I have figured out how to build a query that shows a person who has an expiration date within a specific date range. This is my issue: I have to report how many people have been inactive as follows: within 30 days, 30-60 days, 60-90 days, 90-180 days, over 180 days. I have figured out how to build the queries to show all three credentials that have expired within those date ranges. My problem is that if an individual has say a Drivers License that has expired within 30 days, they will show up in that query but if they have an EMS certification that has expired within 30-60 days, they show up again in the second query. I need to be able to exclude them if they have already been counted. Hope that makes sense. Any help would be greatly appreciated.

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Basically, you want the oldest expiration date. So, if these are the fields:
    Code:
    tblStaff
      StaffID
      ExDate1
      ExDate2
      ExDate3
    Then this gets you the oldest date for each staff member
    Code:
    SELECT
      StaffID,
      IIF(ExDate1 < ExDate2, 
          IIF(ExDate1 < ExDate3, ExDate1, ExDate3), 
          IIF(ExDate2 < ExDate3, ExDate2, ExDate3)
         ) AS OldestDate
    FROM tblStaff;
    And then use Oldestdate to determine the number of days inactive.

    NOTE 1: I'm only testing "less than", because if two expiration dates are the same, then it doesn't matter which one you get.

    NOTE 2: I'm assuming all those dates are filled in and not Null, otherwise you'll need to put NZ() around each of the ExDatex fields.

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

Similar Threads

  1. Query by date for multiple ranges
    By Xarkath in forum Queries
    Replies: 2
    Last Post: 06-11-2013, 01:47 PM
  2. Query for upcoming expiration date
    By jones in forum Queries
    Replies: 2
    Last Post: 05-16-2012, 02:18 AM
  3. Query for gaps in date ranges
    By kagoodwin13 in forum Queries
    Replies: 6
    Last Post: 03-19-2012, 07:00 PM
  4. Query return for date ranges.
    By Desstro in forum Queries
    Replies: 2
    Last Post: 09-14-2010, 06:44 AM
  5. Select Query Using Different Date Ranges
    By Hemi426 in forum Queries
    Replies: 3
    Last Post: 07-26-2010, 01:06 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