Click here to Skip to main content
15,943,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Ms Access database,and used 1 field as data type as date/time

while sending values to this field,its showing an error "data type mismatch in criteria expression"
the value i passed is " calender1.selecteddate()"

After that i used calender1.selecteddate.toshoerdatestirng()
at that time the query worked and value is saved in the field and i can retriev the value
bt in the case of any date i select,the value stored in table is like
if i enterd 3/31/2010,its entered in the field as 12/30/1899,bt i can access the date by checking using 3/31/2010

please give me a solution to solve this

Kishore R
Gis Solutions

See this forum:[^]

I assume you're adding the value using a SQL statment. When you do that, you need to surround the DateTime with #. For example from the forum:
# 16/09/2005 2:38:51 PM #

That tells Access that it is a specific data type.

Alternatively, if you have a DateTime, you could use the ToOADate method. For example:

That will format it correctly for Access.
Share this answer
I do not fully understand your point. Does the Access database store a wrong value? Then try something like
(new System.ComponentModel.DateTimeConverter()).ConvertToInvariantString(myDateValue)

Or is the value in the database correct (check that by opening Access), and you retrieve a wrong value? If so, please show your code for retrieving the date value.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900