Type mismatch?

X

xool

Hi i'm getting a type mismatch error, anyone tell me why pls?


conn.Execute "DELETE FROM Bmemo WHERE (tDate <= '" & date() & "')"


tDate is a date field in an Access database....

Many thanks
 
R

Randy Rahbar

Hi i'm getting a type mismatch error, anyone tell me why pls?

You have to surround the date with pound signs when using Access.

Try this instead:
conn.Execute "DELETE FROM Bmemo WHERE (tDate <= #" & date() & "#)"
 
A

Aaron Bertrand - MVP

Why do you need to pass in the date from ASP? Access knows the date.

conn.Execute "DELETE Bmemo WHERE tDate <= Date()"

As Randy pointed out, if you're passing the date from outside the database,
you need to delimit it correctly.

conn.Execute "DELETE Bmemo WHERE tDate <= #" & Date() & "#"

I might even go so far as to suggest putting the date in an ISO format, e.g.
yyyy-mm-dd, to avoid ambiguity.
 
X

xool

Great that's it, many thanks Randy

Randy Rahbar said:
You have to surround the date with pound signs when using Access.

Try this instead:
conn.Execute "DELETE FROM Bmemo WHERE (tDate <= #" & date() & "#)"
 
A

Aaron Bertrand - MVP

Not to take anything from Randy's answer, but if you use the method I
recommended, you don't have to worry about date formats / regional settings
messing up the interpretation of date() (e.g. if a US-based access database
is placed on a UK server; the internal comparison is much safer than
external).
 
X

xool

Ok will do, many thanks Aaron


Aaron Bertrand - MVP said:
Not to take anything from Randy's answer, but if you use the method I
recommended, you don't have to worry about date formats / regional settings
messing up the interpretation of date() (e.g. if a US-based access database
is placed on a UK server; the internal comparison is much safer than
external).
 

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

Similar Threads

Data Type Mismatch 1
mismatch error 2
Type mismatch problems with select box list 10
Type mismatch 19
select query data type mismatch 3
ASP Dates Display 5
type mismatch 5
Argument count mismatch 6

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top