select records based on DateDiff

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rkferguson
    New Member
    • Apr 2010
    • 1

    select records based on DateDiff

    Hi Folks,

    I have a table that captures information about documents that leave the office.
    Some of those documents may get a signature and then return to the office.

    Need away to query the table and select records that have a field called "expected return" = "Yes", then to compare the date the document left the office to the current date and then, if the Date Returned is blank/empty/null, select that record as a part of a report or query....

    I can attach the table if needed ...
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by rkferguson
    Hi Folks,

    I have a table that captures information about documents that leave the office.
    Some of those documents may get a signature and then return to the office.

    Need away to query the table and select records that have a field called "expected return" = "Yes", then to compare the date the document left the office to the current date and then, if the Date Returned is blank/empty/null, select that record as a part of a report or query....

    I can attach the table if needed ...
    The following SQL Statement will return all Records from Table 1 where the [Expected Return] Field is True, the [Date Returned] Field is Null, and the [Date Left] Field is within the last week:
    Code:
    SELECT * FROM Table1
    WHERE (((Table1.[Expected Return])=True) AND (DateDiff("d",[Date Left],Date())<=7 And 
    DateDiff("d",[Date Left],Date())>0) AND ((Table1.[Date Returned]) Is Null));

    Comment

    • mcupito
      Contributor
      • Aug 2013
      • 294

      #3
      ADezii, in regards to your code, say he/she wants to return them for the last year. Would it be
      Code:
      Date())<= 356
      ?
      Last edited by zmbd; Dec 9 '13, 10:37 PM. Reason: [z{this is a very old thread and this is close to a hijack...}]

      Comment

      Working...