Solved

Access 2007 Date Query Criteria -6 by date

Posted on 2014-09-10
7
505 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 - 06/01/2015

 the query would pull only the dates starting 06/01/2009 to 05/31/2010
0
Comment
Question by:CMILLER
  • 4
  • 2
7 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40315923
Use something like
WHERE DATE BETWEEN DATEADD("yyyy",-6, Date Passed) and DatePassed
0
 

Author Comment

by:CMILLER
ID: 40315927
Thats not working
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40315932
select [datefield]
from tablex
where [datefield] between dateadd("yyyy',-6,[enter Date]) And  dateSerial(Year([Enter Date]) - 5, Month([Enter Date]), 0)
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:CMILLER
ID: 40315936
I am getting a "The expression you entered has an invalid string" A string can be up to 2048 char long, including opening and closing quotation marks
0
 

Author Comment

by:CMILLER
ID: 40315946
found it

("yyyy'
0
 

Author Comment

by:CMILLER
ID: 40315959
is my thinking correct on this?

If I am going back 6 yrs from a date ( 06/15/2015 ) would that be in between 6/01/2009 to 5/31/2010?

or is it between 5/31/2008 to 6/01/2009?
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40315966
Not sure  - open the immediate window of VBA and type in the expression as ?Datevalue(with your details) and see what it returns.


Kelvin
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

758 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

21 Experts available now in Live!

Get 1:1 Help Now