Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem filtering dates 1

Status
Not open for further replies.

RonMcIntire

Technical User
Oct 12, 2002
166
US
All:

I'm querying another query to filter a list of birthdays (Date/Time type) for a range of months and I'm having trouble.

SETUP
In the query, I use the following calculation:
MO: DatePart("m",[birthdate]) 'this gets me the month

To filter for a range, I use the criteria:
Between [Start: (Example: 2)] And [End: (Example: 5)]

PROBLEM
When I ask for a range like
Start: 1 End: 8, I get months 1 thru 8 AND 10 thru 12.

when I ask for a range like
Start: 8 End: 10, I get months 2 thru 8 AND 10 thru 12.

What am I doing wrong and how do I get what I want?

Thanks

Ron
 
Access is treating the result of your 'between' as text. Replace what you had with this:
Code:
Between CInt([Start: (Example: 2)]) And CInt([End: (Example: 5)])
This converts it to integers which I assume is what you are trying to do.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Traingamer:

I just tried the code you suggest and it does exactly what I need.

Thanks for your help.

Ron
 
Skip:

I presume you suggest that the calculation code is:

MO: Month(birthdate)

and the Criteria is

Between [Start: ] and [End: ] where the start value is 1 and the end value is 8.

I tried that with the same results as using the datepart function. The problem is apparently related to the values calculated being Variant Integers which do not sort the same way integer types do.

Thanks for your help anyway.

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top