473,974 Members | 5,939 Online
Bytes | Software Development & Data Engineering Community
+ 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, adLockOptimisti c


It gives the Error "Data type mismatch in citerian expression"
Aug 27 '07 #1
3 2046
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Wrap Date Conditions with #:
For Access :

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

For Oracle :

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


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, adLockOptimisti c

For Oracle :

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


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
2629
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 from a form to a confirmation.asp page. This value is a calculated field. For most cases this session variable value should be zero. However, instead, it is giving null value and this null value is messing up the update statement which is supposed...
2
9820
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. "Tasks.Name" is a "Text" field with description of task, while "DurationHrs" is a VB function that calculates number of hours between two "DateTime" values and returns
1
2122
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. "Tasks.Name" is a "Text" field with description of task, while "DurationHrs" is a VB function that calculates number of hours between two "DateTime" values and returns
2
1748
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 tbl_EquipmentChronology.Outlet = '" & Forms!tbl_PPVResearch_Edit!frm_Events!PPVVOD_Outlet & "';" Set rst = CurrentDb.OpenRecordset(qry) tbl_EquipmentChronology Outlet Number
4
35499
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 miles per day between 2 known dates/mileages and then uses the service schedule to work out what date the next service would be due, selecting the 'closer'
5
1994
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) Dim rs As Object Set rs = Me.Recordset.Clone ' strCriteria = "( = '" & myMR & "')" strCriteria = "( = '" & myDate & "')" rs.FindFirst (strCriteria)
3
3535
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 code: OleDbCommand cmd = new OleDbCommand("select id, endDate from audits where objectId ='" + (int)data + "' order by endDate DESC", conn); try { conn.Open();
3
6805
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, linked by ClientID). When trying to open the report I receive the following error: "Data Type Mismatch in Criteria Expression" The report worked before, so as an experiment I created a new table with a structure identical to tblResult (so I...
1
2604
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) With Adodc2.Recordset
0
10348
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10161
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11563
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8453
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6410
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6546
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.