Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now