Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Access 2007 Date Query Criteria -6

Posted on 2014-09-10
4
454 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

808 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