Solved

selecting/updating date in access db with VB

Posted on 2003-10-28
6
207 Views
Last Modified: 2010-05-01
Hello,
I'm using VB6 and access 97. I have a column that holds the date, the date inserted to the table is taken from the system with this function:
today = Format(Now,"dd/mm/yy"),
the SQL is:
strsql = "INSERT INTO myTable(name,eDate) VALUES ('richard', "   & today & " ' )"
the problem is that when i insert the date as a string with ' ' the date apears good in the table but if i try to execute a select/update by the date then it gives nothing -
SELECT * FROM myTable where eDate = '28/10/03' returns adata type mismatch,
 and when i do
SELECT * FROM myTable where eDate = 28/10/03 then 0 records is returned
note thet when I insert the date without '  ' it inserts random date and time
Hope u can asist me ASAP
thanks

0
Comment
Question by:zolpo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Expert Comment

by:ampapa
ID: 9633602
Try surrounding the date with #28/10/03#
0
 
LVL 1

Author Comment

by:zolpo
ID: 9633659
thanks but ---
I tried already, it didnt work
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 350 total points
ID: 9633663
Hi zolpo,

To add to that, ALWAYS use american or other non-ambiguous date:

"Select * FROM MyTable Where eDate = #" & Format(today,"yyyy-mm-dd") & "#"

Access will always interpret dates based on mm/dd/yy first regardless of the regional settings of the machine. The use of yyyy-mm-dd gets over this problem as this will always be interpreted correctly and will not confuse dates such as 04/05 between 4th may or 5th april.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:zolpo
ID: 9633779
Thanks TimCottee ,
I tried to insert as an american date, but still the select returns 0 records
(the sql is: SELECT * from myTable where eDate = #03/10/28#)
0
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 9633850
SELECT * from myTable where eDate = #2003/10/28# '<-- as per TimCottee's comment 4 digit year.
0
 
LVL 1

Author Comment

by:zolpo
ID: 9634206
Thanks TimCotte,
The problem is solved,
The strange thing is- that when I insert the date to the table then I have to insert it as an american date, and when I'm executing a query that uses the date I write it as an English date, and thats the only way it works!
I guess it is because the design pattern I did on the date column.
thanks You All!!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
message box in access 4 55
How to set the row selection as it was prior leaving the datagrid in vb6 3 60
Child Form in front 4 64
checkbox to hide entire section 10 74
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question