Results 1 to 5 of 5
  1. #1
    romi is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    7

    Filter Query

    Dear All..
    I Have a table Employee

    Employee Name Start Date End Date
    Smith 12/01/2017 12/03/2017
    Jack 12/02/2017 12/05/2017
    Smith 12/05/2017 12/08/2017
    James 12/07/2017 12/09/2017


    I want to assign job Start Date 12/04/2017 and End Date 12/06/2017
    how to make filter query so i can find free employee on that date..?
    The result of query is James 12/07/2017 --- 12/09/2017
    thx

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Should post your attempted query.

    Looks like you want to find employee whose StartDate is on or before the job StartDate AND employee EndDate is on or after job EndDate. Construct WHERE clause accordingly.

    None of the listed employees will meet that criteria.
    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
    romi is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    7
    My query:


    SELECT Schedule.ID, Schedule.[Employee Name], Schedule.[Start Date], Schedule.[End Date]
    FROM Schedule
    WHERE (((Schedule.[Start Date]) Not Between #12/04/2017# And #12/06/2017#) AND ((Schedule.[End Date]) Not Between #12/04/2017# And #12/06/2017#));

    and result:
    Click image for larger version. 

Name:	capture-20171227-001114.png 
Views:	12 
Size:	8.0 KB 
ID:	31793

    but smith still in this result..
    i just want this result only James..

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    These employee start and end dates represent period employee is NOT available?

    SELECT * FROM Employees WHERE NOT [Employee Name] IN (SELECT [Employee Name] FROM Employees WHERE #12/04/2017# BETWEEN [Start Date] AND [End Date] OR #12/6/2017# BETWEEN [Start Date] AND [End Date]);


    Advise no spaces nor punctuation/special characters (underscore only exception) in naming convention.
    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
    romi is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    7
    Thank you Bro June7..
    I combine this query with parameter..
    so my query is:

    PARAMETERS Start DateTime, Finish DateTime;
    SELECT Schedule.ID, Schedule.[Employee Name], Schedule.[Start Date], Schedule.[End Date]
    FROM Schedule
    WHERE NOT [Employee Name] IN (SELECT [Employee Name] FROM Schedule WHERE [Start] BETWEEN [Start Date] AND [End Date] OR [Finish] BETWEEN [Start Date] AND [End Date]);


    the result:
    ID Employee Name Start Date End Date
    4 James 12/07/2017 12/09/2017

    Thank you it solved bro...

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

Similar Threads

  1. Replies: 2
    Last Post: 02-20-2017, 11:28 PM
  2. Filter Query using VBA
    By Blaze83 in forum Access
    Replies: 13
    Last Post: 06-01-2016, 04:25 AM
  3. Replies: 7
    Last Post: 05-27-2015, 12:45 PM
  4. Query, Look-up with filter?
    By CocoPuente in forum Queries
    Replies: 1
    Last Post: 10-08-2014, 11:00 PM
  5. Replies: 2
    Last Post: 01-30-2013, 07:34 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