Solved

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

Posted on 2014-02-06
1
223 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

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!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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