Solved

date stored in access does not match when trying to requery table

Posted on 2014-02-06
1
224 Views
Last Modified: 2014-02-06
Dim dtFirstOfMonth As Date = dtNow.AddDays(-dtNow.Day + 1)
        Dim dt As Date = Date.Parse(dtFirstOfMonth)
        dt = FormatDateTime(dt, DateFormat.ShortDate)
        dayofweeks = dt.DayOfWeek
        dateString = dt

        dateString = Trim(dateString)

dateString is a short date that has #1/1/2014#
when it is stored in access which the field is set to short date it appears as 1/1/2014
when I query I get message mismatch in query.
how do I trim off the # signs from dateString.
tried dateString = dateString.trim(#)  comes back as trim is not a method of date

query line reads:
Dim DaD2 As OleDbDataAdapter = New OleDbDataAdapter("Select * from EmployeeAccumInfo where WORKDATE =  '" & dateString & " '   ", Con)
WORKDATE in this case is would be 1/1/2014 and dateString is #1/1/2014#

thanks

gary
0
Comment
Question by:javagair
[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
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39839728
Change following

dateString = dt

to

either

dateString = dt.ToString("dd/MM/yyyy")

or

dateString = dt.ToString("MM/dd/yyyy")

depending on the format you are using.
0

Featured Post

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 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