A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Data Type Mismatch in Criteria Expression



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2010, 09:39 PM posted to microsoft.public.access
JoeP
external usenet poster
 
Posts: 82
Default Data Type Mismatch in Criteria Expression

In Access 2003 I have a calculated field in a query that is converting a
string of numbers into a date format. The formula for doing this is...
TscDate:
DateSerial(Left([DateInput],4),Mid([DateInput],5,2),Right([DateInput],2)).

The formula works fine but when I enter criteria for the calculated field
(criteria example Between #2010/01/01# and #2010/01/31 I receive a Data Type
Mismatch in Criteria Expression. I am stumped about what I am doing wrong.
Any help would be appreciated. Thanks.

JoeP
  #2  
Old March 1st, 2010, 10:17 PM posted to microsoft.public.access
John Spencer
external usenet poster
 
Posts: 7,815
Default Data Type Mismatch in Criteria Expression

I would try the following.

Field: RealDate:
IIF(IsDate(Format(DateInput,"@@@@-@@-@@")),CDate(Format(DateInput,"@@@@-@@-@@")),Null)

Criteria: Between #2010/01/01# and #2010/01/31#

Your problem could be that Dateinput is blank or null and DateSerial is
generating an error when it tries to process the zero-length strings you are
passing it.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

JoeP wrote:
In Access 2003 I have a calculated field in a query that is converting a
string of numbers into a date format. The formula for doing this is...
TscDate:
DateSerial(Left([DateInput],4),Mid([DateInput],5,2),Right([DateInput],2)).

The formula works fine but when I enter criteria for the calculated field
(criteria example Between #2010/01/01# and #2010/01/31 I receive a Data Type
Mismatch in Criteria Expression. I am stumped about what I am doing wrong.
Any help would be appreciated. Thanks.

JoeP

  #3  
Old March 1st, 2010, 10:31 PM posted to microsoft.public.access
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Data Type Mismatch in Criteria Expression

Try it this way --
Between #01/01/2010# and #01/31/2010#

--
Build a little, test a little.


"JoeP" wrote:

In Access 2003 I have a calculated field in a query that is converting a
string of numbers into a date format. The formula for doing this is...
TscDate:
DateSerial(Left([DateInput],4),Mid([DateInput],5,2),Right([DateInput],2)).

The formula works fine but when I enter criteria for the calculated field
(criteria example Between #2010/01/01# and #2010/01/31 I receive a Data Type
Mismatch in Criteria Expression. I am stumped about what I am doing wrong.
Any help would be appreciated. Thanks.

JoeP

  #4  
Old March 13th, 2010, 05:56 PM posted to microsoft.public.access
De Jager
external usenet poster
 
Posts: 393
Default Data Type Mismatch in Criteria Expression


"JoeP" wrote in message
...
In Access 2003 I have a calculated field in a query that is converting a
string of numbers into a date format. The formula for doing this is...
TscDate:
DateSerial(Left([DateInput],4),Mid([DateInput],5,2),Right([DateInput],2)).

The formula works fine but when I enter criteria for the calculated field
(criteria example Between #2010/01/01# and #2010/01/31 I receive a Data
Type
Mismatch in Criteria Expression. I am stumped about what I am doing wrong.
Any help would be appreciated. Thanks.

JoeP


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.