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  dBforums > Database Server Software > Other > Access - Can do date filtering?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-05-04, 09:53
hocksoo hocksoo is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
Access - Can do date filtering?

I'm currently using Asp with Access as DB. I have a sql select statement which require date filtering. However, I keep on getting the following error:

Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.

My sql statement is something like this:
" where Date between '#"&fDateFr&"#' and '#"&fDateTo&"#'"

Can anyone tell me whether access can do date filtering?
Reply With Quote
  #2 (permalink)  
Old 02-05-04, 13:31
AZ KC AZ KC is offline
Registered User
 
Join Date: Feb 2004
Posts: 142
Re: Access - Can do date filtering?

Quote:
Originally posted by hocksoo
I'm currently using Asp with Access as DB. I have a sql select statement which require date filtering. However, I keep on getting the following error:

Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.

My sql statement is something like this:
" where Date between '#"&fDateFr&"#' and '#"&fDateTo&"#'"

Can anyone tell me whether access can do date filtering?
By using the single quotes you have cast the dates and #s as a string. Remove the single quotes and it should work.
__________________
KC
Reply With Quote
  #3 (permalink)  
Old 02-06-04, 10:11
hocksoo hocksoo is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
Smile

Thank you. I have have solve the problem!!!
Reply With Quote
  #4 (permalink)  
Old 02-06-04, 11:11
sundialsvcs sundialsvcs is offline
Registered User
 
Join Date: Oct 2003
Posts: 706
Yeah. The first example constructed:

date between '#01/01/2003#' ...

which, because of the presence of the quotes, Access interpreted to be a string literal (which, as it happens, consists of a funky-lookin' mixture of "#"s and "/"s and digits).

For a date-type literal in Access, the "#"s are the delimeters:

date between #01/01/2003# ...

Also, nit-pickin' here: I suggest that you avoid using column-names, like Date, which match SQL reserved-words. Although MS-Access can resolve the ambiguity by enclosing the offending names in square brackets, other SQL dialects may not support this syntax and what you'll be left with is an application that can't readily be "upsized" to a different platform. Use more descriptive titles, like OrderDate.
__________________
ChimneySweep(R): fast, automatic
table repair at a click of the
mouse! http://www.sundialservices.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On