Dynamic Queries & Data Type Mismatch Errors

bwyrwitzke

Registered User.
Local time
Today, 14:22
Joined
Nov 11, 2002
Messages
50
Hi All,
Hopefully you all can knock some sense into me on this one. I'm creating a dynamic query with a calculated date function that only works part of the time.

This works:

Code:
SELECT s.*, DateDiff("d",s.DSP_Trained_Date,date()) AS Expr1

FROM tblPersonnel AS s

WHERE (DateDiff("d",s.DSP_Trained_Date,date()))<365 AND s.View =True AND s.Contractor1=True

ORDER BY s.[Last Name], s.[First Name], s.Organization;

This returns a Data Type Mismatch in Criteria Expression:

Code:
SELECT s.*, DateDiff("d",s.DSP_Trained_Date,Date()) AS Expr1

FROM tblPersonnel AS s

WHERE (((DateDiff("d",[s].[DSP_Trained_Date],Date()))<365) AND ((s.View)=True))

ORDER BY s.[Last Name], s.[First Name], s.Organization;

The only difference is the additional criteria (and brackets & parenthesis) that gets added. Why does one work and the other not??? Thanks in advance.

Bruce
 
Never mind!

Sorry for bothering you all with this. It was an error in my tables that was causing problems. One of the dates was entered as 00/00/0000 rather than blank or a valid date.


Bruce
 

Users who are viewing this thread

Back
Top Bottom