Results 1 to 5 of 5
  1. #1
    Marnhullman is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    5

    Retrieve record for specific date which is stored with Effective and Inactive dates

    I have a table that stores records each with two date fields - an Effective (start) date and Inactive (end) date.

    How do I retrieve a record for a specific date e.g. with a record that has a Start date of 01/03/2023 and an End date of 10/04/2023 how do I retrieve the record for 23/03/2023?

    Also how would I retrieve multiple records for a range of dates e.g. a record for each day between 06/03/2023 and 05/04/2023? I can generate a table with the required date range but can't figure out how to join or use it to run a query that will produce a record for each date in the range.



    Thanks

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Your criteria would be something like

    where start date<=[enter date] and enddate >=[enter date]

    depends wether you want to include records that start or end on the required date as to using the =

    and depends on how you are doing this - if using msgbox or creating a query in vba you will need to format the date string and surround with the # character

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You want to retrieve any records where a given date falls between Effective and Inactive?

    WHERE [enter given date] BETWEEN Effective AND Inactive

    BETWEEN AND is inclusive of range ends

    You show date values in non-U.S. format - that could be an issue. Review http://allenbrowne.com/ser-36.html
    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
    Marnhullman is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    5
    Thanks. I think I've tried your suggestions amongst the various options I've used but will give it a go later.

    Regards

  5. #5
    Marnhullman is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    5
    Thank you June7 your answer works!

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

Similar Threads

  1. Replies: 2
    Last Post: 04-20-2016, 03:41 AM
  2. Selecting field based on effective date
    By Luffk73 in forum Access
    Replies: 1
    Last Post: 03-30-2015, 12:40 PM
  3. Replies: 1
    Last Post: 03-23-2015, 09:42 AM
  4. Replies: 1
    Last Post: 11-22-2013, 12:30 PM
  5. Retrieve images stored as file paths in Access
    By Nonz in forum Programming
    Replies: 4
    Last Post: 09-26-2011, 06:46 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