Solved

Access 2007 Date Query Criteria -6

Posted on 2014-09-10
4
448 Views
Last Modified: 2014-09-10
I need help with a query on one of my tables. On one of the table fields there is a date mm/dd/yyyy. I need to have the user input a future date and then count back 6 years from the table field date. I only want to see the dates that fall in the 6 year window.

ex: user input - 01/01/2015

the query would pull only the dates starting 01/01/2009 to 01/01/2015
0
Comment
Question by:CMILLER
  • 2
  • 2
4 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40315788
select [datefield]
from tablex
where  [datefield] Between Dateadd("yyyy",-6,[Enter Date]) And [Enter Date]
0
 

Author Comment

by:CMILLER
ID: 40315793
Sorry, I just realized that I posted the query wrong.

ex: user input - 01/01/2015

 the query would pull only the dates that are in the 6th year, which would be all of 2009
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40315801
select [datefield]
 from tablex
 where  Year([datefield]) = Year(Dateadd("yyyy",-6,[Enter Date]))
0
 

Author Comment

by:CMILLER
ID: 40315907
Sorry, I had it wrong again.

I posted another question.

http://www.experts-exchange.com/Database/MS_Access/Q_28515939.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now