By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,455 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,455 IT Pros & Developers. It's quick & easy.

select records based on DateDiff

P: 1
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 ...
Apr 30 '10 #1
Share this Question
Share on Google+
2 Replies


ADezii
Expert 5K+
P: 8,597
@rkferguson
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:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM Table1
  2. WHERE (((Table1.[Expected Return])=True) AND (DateDiff("d",[Date Left],Date())<=7 And 
  3. DateDiff("d",[Date Left],Date())>0) AND ((Table1.[Date Returned]) Is Null));
Apr 30 '10 #2

100+
P: 294
ADezii, in regards to your code, say he/she wants to return them for the last year. Would it be
Expand|Select|Wrap|Line Numbers
  1. Date())<= 356 
?
Dec 9 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.