From: WDSnews on
[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?


From: WDSnews on
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" <wdsnews.0640(a)oregoncity.com> wrote in message
news:OoxfHx98KHA.1892(a)TK2MSFTNGP05.phx.gbl...
> [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?
>


From: Tom van Stiphout on
On Fri, 14 May 2010 20:56:03 -0700, "WDSnews"
<wdsnews.0640(a)oregoncity.com> wrote:

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" <wdsnews.0640(a)oregoncity.com> wrote in message
>news:OoxfHx98KHA.1892(a)TK2MSFTNGP05.phx.gbl...
>> [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?
>>
>