473,473 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

60 New Member
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 2026
QVeen72
1,445 Recognized Expert Top Contributor
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
vishwaskothari
60 New Member
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 Top Contributor
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

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

Similar topics

7
by: Jack | last post by:
Hi, I have posted this problem before. Apprently, the suggestion took care of the problem. However, still I am getting the above error message. I am using a session variable to transfer a value...
2
by: igor.barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
1
by: Igor Barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
2
by: Eric | last post by:
Why it gives that error. Both tables have same type of number Data type mismatch qry = "SELECT tbl_EquipmentChronology.Equipment1 FROM tbl_EquipmentChronology WHERE...
4
by: bleighfield | last post by:
Hi everyone Hope someone can help with this one.. Background: I work in vehicle fleet, I have built something to 'predict' when a car/van service is due (it's fairly simple, calculates...
5
by: isoquin | last post by:
The below code throws the error: "Data type mismatch in criteria expression" Searching online didn't seem to offer me a solution. Public Sub update_by_EDD(myDate As Date, myMR As String) ...
3
Kermit
by: Kermit | last post by:
Hi. Here's the problem. I use C# application to access MSAccess database. I want to get id's of all records containing some phrase and order results by date (a field in the table). here's the...
3
by: martin DH | last post by:
I would definitely appreciate any help with this problem as soon as possible. Thanks! I have a report that should display the results of a query based on two tables (tblClient and tblResult,...
1
by: Ferwayne Yalung | last post by:
How can i fix the error? Private Sub cmdadd2_Click() If cmdadd2.Caption = "ADD" Then cmdadd2.Caption = "SAVE" cmdedit2.Caption = "CANCEL" buttons True, False a = Date a = Right(a, 4) ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.