Board index » delphi » Problem with SQL query (Delphi 5 and MSAccess 97)

Problem with SQL query (Delphi 5 and MSAccess 97)

I'm having problems executing the following query from a TQuery:

SELECT ProjectID, SUM(Minutes)
FROM tblTime
WHERE Date>= '05/07/2000' and Date<= '05/13/2000'
GROUP BY ProjectID

If I use single quotes around the dates, I get the error message 'Data
type mismatch in criteria expression'.  If I use double quotes around
the dates, I get the error message 'Too few parameters. Expected 2.'  If
I use no quotes around the dates, I get no errors and no data returned.

The Date field in the MSAccess database is a DateTime.  I'm sure I'm not
formatting something correctly so that is my question, how do I format
the WHERE criteria?

Thanks in advance,
David Maddox

 

Re:Problem with SQL query (Delphi 5 and MSAccess 97)


Access does not use standard SQL. Try

SELECT ProjectID, SUM(Minutes)
FROM tblTime
WHERE Date>= #05/07/2000# and Date<= #05/13/2000#
GROUP BY ProjectID

--
Bill Todd (TeamB)
(Questions received via email cannot be answered.)

Re:Problem with SQL query (Delphi 5 and MSAccess 97)


Quote
marcfmd wrote in message <39999121.3098C...@concentric.net>...
>I'm having problems executing the following query from a TQuery:

>SELECT ProjectID, SUM(Minutes)
>FROM tblTime
>WHERE Date>= '05/07/2000' and Date<= '05/13/2000'
>GROUP BY ProjectID

>If I use single quotes around the dates, I get the error message 'Data
>type mismatch in criteria expression'.

Access does not use standard SQL. I don;t personally know Access but from
other posts I've seen I believe the syntax is:

WHERE Date>= #05/07/2000# and Date<= #05/13/2000#

--
Wayne Niddery (WinWright Inc.)
RADBooks - http://members.home.net/wniddery/
Helicopters can't fly; they're just so ugly the earth repels them.

Other Threads