Finding a date range with a SQL statement.

Posted on 2003-02-20
Medium Priority
Last Modified: 2010-04-07
Hello everyone!!!

Im a VB newbie and need some help.  Im connecting to an Access DB using ADODC, I need to be able to show a date range defined by the user using two text boxes.  Maybe even better a way to show the current date and the previous seven days to that.  If any of this is at all possible any answer woud be greatly appreciated, thanks!!!
Question by:lopez22
LVL 14

Accepted Solution

jjardine earned 200 total points
ID: 7988303
You can use the Date Function to get todays date   and I believe if you wanted to get the date 7 days ago you could do something like

oldDate = DateAdd("d",-7,Date)    'this should return it.

You would then pass your two dates in your SQL Statement with   a where clause of WHERE 'Date field' Between '#oldDate#' AND '#Date#'

Hope that helps give some idea.  Good Luck

Expert Comment

ID: 7989589
MyDateA = Date()      'This is Today
MydateB = Date() - 1  'This is yesterday
MydateC = Date() - 2  'This is the day befor yesterday


Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

612 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