Or try using single quotes around the date as well (if DB version is Access 2003 with "SQL Server Compatible Syntax" (ANSI 92))
conn.Execute "INSERT INTO my_ado(id,name,dt) values(1,100,'04/22/2007')
Main Topics
Browse All TopicsHello all,
I have a problem which I cant solve
I want to create a date col. with the format "DD/MM/YYYY" in access daabase. however, I can't do this. Does anyone have a solution to this? I've searched a lot in the web but coudnlt find a sol.
here is my code:
Set conn = New ADODB.Connection
' conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
& "SERVER=localhost;" _
& " DATABASE=test;" _
& "UID=root;PWD=; OPTION=3"
conn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" _
& "c:\temp" & "\" & "db1.mdb" & " ; DefaultDir=" & "c:\temp\" & ";"
conn.Open
'create table
conn.Execute "DROP TABLE IF EXISTS my_ado"
conn.Execute "CREATE TABLE my_ado(id int not null primary key, name varchar(20)," _
& "txt text, dt date, tm time, ts timestamp)"
'direct insert
conn.Execute "INSERT INTO my_ado(id,name,dt) values(1,100,22/04/2007)" ' ERROR
conn.Close
Thanks in advance,
Eyal
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
http://www.experts-exchang
A date field in the database does not have a format. When you work with access, it will display based on the locale of the machine the code is running on.
I'd recommend you format it like:
INSERT INTO my_ado(id,name,dt) values(1,100,'22/apr/2007'
Business Accounts
Answer for Membership
by: sirbountyPosted on 2007-04-10 at 14:30:45ID: 18885602
Try: " "
conn.Execute "INSERT INTO my_ado(id,name,dt) values(1,100,#04/22/2007#)
or
conn.Execute "INSERT INTO my_ado(id,name,dt) values(1,100,#22/04/2007#)