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

Find Previous Record

P: 77
I have a query that has the following fields/data,

ID, Seq, EDate, TDate;
3228, 1, 6/30/2008, 8/7/2008
3228, 1, 6/30/2008, 6/18/2008
3228, 1, 6/30/2008, 3/22/2005
3228, 1, 6/30/2008, 3/21/2000

I need to find the record where TDate is < EDate by 12 months.
I am not sure how to read thru all the records and find out which one has a TDate that is 12 months less then EDate.

Please treat this a urgent.

Aug 27 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 8,692
To find all Records in which TDate is at least 12 Months earlier than EDate, try:
Expand|Select|Wrap|Line Numbers
  1. DateDiff("m",[TDate],[EDate]) >= 12
Aug 27 '08 #2

Expert 2.5K+
P: 2,653
Hello, AccessHunter.

You indeed didn't provide sufficient information on your problem.
It is a good idea to post a query SQL as soon as the whole question is all about the query. Also you havn't specified what do you mean by 12 months difference - is it supposed to be the same date 12 months ago or any date in month-12?

Anyway, below are
WHERE clause for month-12
Expand|Select|Wrap|Line Numbers
  1. ... WHERE DateDiff("m", TDate, EDate) = 12
to check for the same date 12 months before just add an additional condition
Expand|Select|Wrap|Line Numbers
  1. ... WHERE Day(EDate) = Day(TDate) AND DateDiff("m", TDate, EDate) = 12
Aug 27 '08 #3

Post your reply

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