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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Parameter query

Status
Not open for further replies.

rooterr

Technical User
May 15, 2001
21
0
0
US
I have a query that I want to have a parameter where the user enters in the starting quarter and year and the ending quarter and year and the results show everything between. I currently have all of the information going in, but I used between starting quarter and ending quarter. Then in the next field I have starting year and ending year. This gives me all of the information for the quarter range I enter over the years I enter.

Example
starting quarter = 1 Ending quarter = 2 starting year = 2002 ending year = 2003

My results would show all of the events that occurred in the first two quarters of 2002 and 2003. I want it to show everything between quarter 1 of 2002 and quarter 2 of 2003. I am sure there is something really easy here that I am overlooking, but I just cant figure it out any suggestions are appreciated.
 
What are your fields that you are setting the criteria for? Do you just have a date field or do you have a quarter field and a year field?

I think the answer to your question is to use >= the first set and <= the second set. If you have a quarter field and a year field then it will actually have to be &quot;>=1st quarter and =year1 OR <=2nd quarter and =year2&quot;...does that make sense? I'd be happy to help, but just need some more information.

Kevin
 
I would try converting to dates as follows and doing a date comparison:
[tt]
SELECT *
FROM YourTable
WHERE CDate((Quarter*3) & '/1/' & [Year]) Between
CDate((BeginQuarter*3) & '/1/' & BeginYear) And
CDate((EndQuarter*3) & '/1/' & EndYear)
[/tt]
 
Thank both of you for your responses. Godawgs it took me a little while to open my mind up to realize the simplicity of what you were saying. It worked like a charm. I had a quarter and year field in my query based off of the target date using the datepart function. So I used your second suggestion and it is working great now.

Thanks
Roger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top