TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lewis Houlden
NA
1
1.5k
C# Visual Studio MSAcess Query using BETWEEN incorrect
Aug 13 2014 3:21 PM
Hi All
I am fairly new to C# but normally can understand why something isn't working. However, I have a query that works as follows:
Whatever the date is in the DateTimePicker, return rows from MS Access database that are up to 7days ago and ahead (giving a 2 week window).
Query is written as follows:
String str = "SELECT [Date Submitted], [Category], [Description], [Estimated Time], [Day(s) Planned For] FROM WLP WHERE [Date Submitted] Between #" + DTP_DateTime.Value.AddDays(-7) + "# AND #" + DTP_DateTime.Value.AddDays(7) + "#";
Fairly simple query. I've used MessageBox to display the dates when -7 and +7 and they look absolutely fine. It's displaying the correct range.
An example is for today, show me all records between 06/08/2014 and 20/08/2014. However, it still returns results such as 01/08/2014, 04/08/2014, 05/08/2014. Interesting, if I change the date to way out the range, for example, 01/01/2014 it does not display it.
This lead me to believe it is a Culture issue as it's using it as an american date. I then added Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); to try and fix it but still no luck! Am I missing something incredibly easily!
Hope you can help! Thanks for your time in advance :-)
Reply
Answers (
1
)
How to Convert Multiple excel files to CSV using SSIS
How to receive a mail from Gmail using windows application