470,596 Members | 1,689 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Error!!! Data type Mismatch (Problem in comparing 2 dates)

What is wrong in the following Statement?



Dim mydate As Date
Format(mydate, "m/d/yy")

rs.Open "SELECT * from accounts where date='" & mydate & "';", con, adOpenStatic, adLockOptimistic


It gives the Error "Data type mismatch in citerian expression"
Aug 27 '07 #1
3 1804
QVeen72
1,445 Expert 1GB
Hi,

Wrap Date Conditions with #:
For Access :

rs.Open "SELECT * from accounts where date=#" & mydate & "#", con, adOpenStatic, adLockOptimistic

For Oracle :

rs.Open "SELECT * from accounts where date=To_Date('" & mydate & "','m/d/yy')", con, adOpenStatic, adLockOptimistic


REgards
Veena
Aug 27 '07 #2
Hi,

Wrap Date Conditions with #:
For Access :

rs.Open "SELECT * from accounts where date=#" & mydate & "#", con, adOpenStatic, adLockOptimistic

For Oracle :

rs.Open "SELECT * from accounts where date=To_Date('" & mydate & "','m/d/yy')", con, adOpenStatic, adLockOptimistic


REgards
Veena

ya its working
Thanks a Lot
Aug 27 '07 #3
hariharanmca
1,977 1GB
ya its working
Thanks a Lot
'm' will reffer Munit of time

only 'MM' or 'M' will only reffer Month of date.

Just check it.
Aug 27 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Eric | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.