Between Dates parameter query

D

Dustin Swartz

This seems like it should be simple yet I can't get it to work.

I want to run the following query based upon a user selected date range
(OsObj.Datum) being the date record.


PARAMETERS [Begin Date] DateTime, [End Date] DateTime;
SELECT OsObj.Datum, OsPos.PosNr, OsPos.Bez, Min(OsPos.SumMat) AS
MinOfSumMat, OsObj.Bez, Count(OsObj.Bez) AS [Count of Jobs]
FROM OsObj INNER JOIN OsPos ON OsObj.ObjNr = OsPos.ObjNr
GROUP BY OsObj.Datum, OsPos.PosNr, OsPos.Bez, OsObj.Bez
HAVING (((OsObj.Datum) Between "Begin Date" And "End Date"));


Am I way off base?
 
A

Allen Browne

Use square brackets around the parameter names, not quotes:
HAVING OsObj.Datum Between [Begin Date] And [End Date]

It may be more efficient to use a WHERE clause than a HAVING clause.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top