Data Type mismatch error

W

WDSnews

[End Time] is a text field in the [Classes Proposed] table.

This query

SELECT [Classes Proposed].ID, DatePart("h",[Classes Proposed].[End Time]) AS
EndHour
FROM [Classes Proposed]
WHERE (((DatePart("h",[Classes Proposed].[End Time]))<6));

and this query

SELECT [Classes Proposed].ID, DatePart("h",CDate([Classes Proposed].[End
Time])) AS EndHour
FROM [Classes Proposed]
WHERE (((DatePart("h",CDate([Classes Proposed].[End Time])))<6));

work as soon as I remove the WHERE clause. However, with the criteria I get
this error

"Data type mismatch in criteria expression".

Why is <6 in the criteria line giving me trouble?
 
W

WDSnews

I found it. One of the records contained an invalid time.... which
emphasizes my reason to convert from text fields to date/time fields.
 
T

Tom van Stiphout

On Fri, 14 May 2010 20:56:03 -0700, "WDSnews"

Good for you. I have been following this thread. The general rule is:
choose the most restrictive data type that fits the data to be
entered.
One exception is Integer data type. On most computers today, a 32-bit
integer is the standard data type the CPU works with. Each CPU
register is 32-bit. So finessing things and saying this variable is a
byte, this one a 16-bit integer, etc. often is counter-productive at
least from a performance point of view.
So if I have a number to store, and its value can be 0 - 5, I may
still want to use a Long Integer, because the average CPU makes minced
meat of this, while it requires extra cycles to discriminate between
byte and int16, etc.

-Tom.
Microsoft Access MVP

I found it. One of the records contained an invalid time.... which
emphasizes my reason to convert from text fields to date/time fields.




WDSnews said:
[End Time] is a text field in the [Classes Proposed] table.

This query

SELECT [Classes Proposed].ID, DatePart("h",[Classes Proposed].[End Time])
AS
EndHour
FROM [Classes Proposed]
WHERE (((DatePart("h",[Classes Proposed].[End Time]))<6));

and this query

SELECT [Classes Proposed].ID, DatePart("h",CDate([Classes Proposed].[End
Time])) AS EndHour
FROM [Classes Proposed]
WHERE (((DatePart("h",CDate([Classes Proposed].[End Time])))<6));

work as soon as I remove the WHERE clause. However, with the criteria I
get this error

"Data type mismatch in criteria expression".

Why is <6 in the criteria line giving me trouble?
 

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