Results 1 to 8 of 8
  1. #1
    MSAccessOldTimer is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    46

    Query on Date Field plus "X" Number of Days

    My query is built on a table which contains a date field "A". I need to return only those records where field "A" is 56 days past the date in each record. Using Date()+56 shows the records based on today's date plus 56 days, not 56 days past the actual date "A" recorded in each record.



    I appreciate any assistance!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Date is a reserved word in Access with explicit meaning.
    It seems you are seeking criteria for your query.
    Something like

    Code:
    Select * from YourTable
    Where [your datefieldA] + 56 =Date

  3. #3
    MSAccessOldTimer is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    46
    So does that go in the criteria area for DateFieldA in the query? I tried it and got a syntax error message. I should point out that there are 5 other fields that are also in the query, so the query is not just based on DateFieldA.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Can you select the SQL View of the query; then copy the code and post it?

  5. #5
    MSAccessOldTimer is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    46
    DateFieldA is bolded. Thank you!

    SELECT [1-qryAssociates-Active].Badge, [1-qryAssociates-Active].Associate, [1-qryAssociates-Active].Section, [1-qryAssociates-Active].ForktruckTempLicense, [1-qryAssociates-Active].Forktruck_2yrLicense, [1-qryAssociates-Active].ForktruckActive
    FROM [1-qryAssociates-Active]
    WHERE ((([1-qryAssociates-Active].ForktruckTempLicense)<Date()-56) AND (([1-qryAssociates-Active].Forktruck_2yrLicense) Is Null) AND (([1-qryAssociates-Active].ForktruckActive)="-1"));

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Is ForktruckActive a Boolean Yes/No field?

    If so, you might try
    Code:
    SELECT [1-qryAssociates-Active].Badge
    , [1-qryAssociates-Active].Associate
    , [1-qryAssociates-Active].Section
    , [1-qryAssociates-Active].ForktruckTempLicense
    , [1-qryAssociates-Active].Forktruck_2yrLicense
    , [1-qryAssociates-Active].ForktruckActive
    FROM [1-qryAssociates-Active]
    WHERE ((([1-qryAssociates-Active].ForktruckTempLicense)<Date()-56) AND
     (([1-qryAssociates-Active].Forktruck_2yrLicense) Is Null) AND 
    (([1-qryAssociates-Active].ForktruckActive)= True));
    If you need more assistance, I suggest you post a copy of your database. If the data is private/personal, you could use names like Porky Pig, John Doe etc. We don't need real data, but more interested in the structure and logic.
    Good luck.

  7. #7
    MSAccessOldTimer is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Posts
    46
    Yes, that is correct, the ForktruckActive field is yes/no. And thank you Orange...that codes works perfectly!!


  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

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

Similar Threads

  1. Replies: 2
    Last Post: 07-07-2021, 02:53 PM
  2. Evaluate the number in a text field prefixed by "<" or ">"
    By Glen Simple Scientist in forum Programming
    Replies: 7
    Last Post: 12-30-2020, 08:00 AM
  3. Replies: 4
    Last Post: 11-14-2019, 11:30 AM
  4. Replies: 3
    Last Post: 12-06-2014, 03:59 AM
  5. Replies: 2
    Last Post: 09-29-2012, 11:22 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