UPDATE:
1) Are my primary keys, which I understand are the initial index.
2) If I use the above SQL:
Code:
WHERE (FIELD1 Between [FIELD1 yyyymm?] and ([FIELD1 yyyymm?]-200))
then it takes approx 35min to run. If I simplify the code to a single string to MATCH against:
Code:
WHERE (FIELD1 ="201006")
it comes back in seconds.
So what appears to be occurring is the BETWEEN function requires a numeric range and so I assume the query has to first convert each record in FIELD1 to a number (essentiall CLng()) and then perform the logic to see if it is in the range. This is a problem because using CLng() takes forever (my experience with this function via the ODBC connection to the table) and/or it doesn't utilize the indexing!
To test this hypothesis I ran a query with this:
Code:
(RUNYYMM In ("201006","201005","201004","201003","201002","201001","200912","200911","200910","200909","200908","200907","200906","200905","200904","200903","200902","200901","200812","200811","200810","200809","200808","200807","200806"))
and this came back in 11min. However, this disables the usefulness of my parameter query... not essential, but I would like to maintain this function.
3) So is there a way to utilize user input, of a single date (YYYYMM), to generate the last two years worth of data through a single query? (Utilizing the index on the text field)
The only way I can think of to take a single date and modify it to my needs is with VBA, and while I can do that, I'd like to know if a query-only solution is possible.