Les Isaacs
Registered User.
- Local time
- Today, 22:30
- Joined
- May 6, 2008
- Messages
- 186
Hi All
This works fine...
SELECT [qry Submissionsheets].[Employee Name], CDate(CDate([Sickness - Start Date])-Weekday(CDate([Sickness - Start Date]))+1*[tblCount].[CountID]) AS AbsenceDate, Val(DateDiff("d",[Sickness - Start Date],[Sickness - End Date])) AS Expr2
FROM tblCount, [qry Submissionsheets] INNER JOIN staffs ON [qry Submissionsheets].[Employee Name] = staffs.staff_name
WHERE (((CDate(CDate([Sickness - Start Date])-Weekday(CDate([Sickness - Start Date]))+1*[tblCount].[CountID])) Between CDate([Sickness - Start Date]) And CDate([Sickness - End Date])) AND ((IsDate([Sickness - Start Date]))=True) AND ((IsDate([Sickness - End Date]))=True))
ORDER BY [qry Submissionsheets].[Employee Name];
... but when I just add a criteria for Expr2 and rerun the query - on the same data - (so the query becomes as below) I get a Data type mismatch error!! I've used the IsDate function to check that I have dates where expected, and used Val on Expr2 to ensure that I have a numeric value, and when I run the query above, without the criteria, I get the correct results for Expr2. But with any criteria at all for Expr2 I get a Data type mismatch error.
Hope someone can help - this is driving me nuts.
The query that errors is:
SELECT [qry Submissionsheets].[Employee Name], CDate(CDate([Sickness - Start Date])-Weekday(CDate([Sickness - Start Date]))+1*[tblCount].[CountID]) AS AbsenceDate, Val(DateDiff("d",[Sickness - Start Date],[Sickness - End Date])) AS Expr2
FROM tblCount, [qry Submissionsheets] INNER JOIN staffs ON [qry Submissionsheets].[Employee Name] = staffs.staff_name
WHERE (((CDate(CDate([Sickness - Start Date])-Weekday(CDate([Sickness - Start Date]))+1*[tblCount].[CountID])) Between CDate([Sickness - Start Date]) And CDate([Sickness - End Date])) AND ((IsDate([Sickness - Start Date]))=True) AND ((IsDate([Sickness - End Date]))=True) AND ((Val(DateDiff("d",[Sickness - Start Date],[Sickness - End Date])))=3))
ORDER BY [qry Submissionsheets].[Employee Name];
Many thanks
Les
This works fine...
SELECT [qry Submissionsheets].[Employee Name], CDate(CDate([Sickness - Start Date])-Weekday(CDate([Sickness - Start Date]))+1*[tblCount].[CountID]) AS AbsenceDate, Val(DateDiff("d",[Sickness - Start Date],[Sickness - End Date])) AS Expr2
FROM tblCount, [qry Submissionsheets] INNER JOIN staffs ON [qry Submissionsheets].[Employee Name] = staffs.staff_name
WHERE (((CDate(CDate([Sickness - Start Date])-Weekday(CDate([Sickness - Start Date]))+1*[tblCount].[CountID])) Between CDate([Sickness - Start Date]) And CDate([Sickness - End Date])) AND ((IsDate([Sickness - Start Date]))=True) AND ((IsDate([Sickness - End Date]))=True))
ORDER BY [qry Submissionsheets].[Employee Name];
... but when I just add a criteria for Expr2 and rerun the query - on the same data - (so the query becomes as below) I get a Data type mismatch error!! I've used the IsDate function to check that I have dates where expected, and used Val on Expr2 to ensure that I have a numeric value, and when I run the query above, without the criteria, I get the correct results for Expr2. But with any criteria at all for Expr2 I get a Data type mismatch error.
Hope someone can help - this is driving me nuts.
The query that errors is:
SELECT [qry Submissionsheets].[Employee Name], CDate(CDate([Sickness - Start Date])-Weekday(CDate([Sickness - Start Date]))+1*[tblCount].[CountID]) AS AbsenceDate, Val(DateDiff("d",[Sickness - Start Date],[Sickness - End Date])) AS Expr2
FROM tblCount, [qry Submissionsheets] INNER JOIN staffs ON [qry Submissionsheets].[Employee Name] = staffs.staff_name
WHERE (((CDate(CDate([Sickness - Start Date])-Weekday(CDate([Sickness - Start Date]))+1*[tblCount].[CountID])) Between CDate([Sickness - Start Date]) And CDate([Sickness - End Date])) AND ((IsDate([Sickness - Start Date]))=True) AND ((IsDate([Sickness - End Date]))=True) AND ((Val(DateDiff("d",[Sickness - Start Date],[Sickness - End Date])))=3))
ORDER BY [qry Submissionsheets].[Employee Name];
Many thanks
Les