[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2014-02-06
1
Medium Priority
?
227 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
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 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