Link to home
Start Free TrialLog in
Avatar of Chris Miller
Chris MillerFlag for United States of America

asked on

Access 2007 Date Query Criteria -6 by date

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
Avatar of Kelvin Sparks
Kelvin Sparks
Flag of New Zealand image

Use something like
WHERE DATE BETWEEN DATEADD("yyyy",-6, Date Passed) and DatePassed
Avatar of Chris Miller

ASKER

Thats not working
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
found it

("yyyy'
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?
Not sure  - open the immediate window of VBA and type in the expression as ?Datevalue(with your details) and see what it returns.


Kelvin