[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Access 2007 query between two dates

Posted on 2010-09-14
9
Medium Priority
?
708 Views
Last Modified: 2013-11-30
This is the first time I have ever tried to query for something other than an exact value found in a table. I simply have 4 fields  Name, Hours, StartDate, EndDate. I would like to be able to enter any of the following criteria and return records matching the criteria. My difficulty is that I don't know what to do for the dates. Do I need a table that will store these four values? Can I create a temporary variable? Where do I specify the search criteria? Query? Function?

Thanks in advance!
0
Comment
Question by:timamartin
  • 4
  • 4
9 Comments
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33675094
Whats the criteria?
are the 4 fields in the same table?
0
 

Author Comment

by:timamartin
ID: 33675122
The original table has 10 fields I created a new table to store the user inputs that has 4+1 fields.
0
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33675133
what are you wanting to query?
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 

Author Comment

by:timamartin
ID: 33675164
I would like to search for all records between date "A" and date "B" as well as optionally name and hours.
0
 
LVL 13

Expert Comment

by:MWGainesJR
ID: 33675181
select name, hours from table where startdate >= date and enddate<= date
0
 

Author Comment

by:timamartin
ID: 33675226
startdate >= date and enddate<= date

So where do the values stardate and enddate get stored prior to passing them to a query?
0
 
LVL 1

Expert Comment

by:innosys
ID: 33675314
cdate is a function will help you build a date from string and the you can compare dates with it
try it
0
 
LVL 13

Accepted Solution

by:
MWGainesJR earned 2000 total points
ID: 33675416
sub query()
dim sdate as string
dim edate as string
dim qry as string

sdate = format(inputbox("Enter Start Date"), "mm/dd/yyyy")
edate = format(inputbox("Enter End Date), "mm/dd/yyyy")
qry = "Select name, hours from table where startdate >= " & sdate & " and enddate <= " & edate
'rest of code (recordset or output to spreadsheet or file)
end sub
0
 

Author Closing Comment

by:timamartin
ID: 33675438
Ohhhhhh...I see. Thanks for your assistance that is what I need.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Check out the latest tech news, community articles, and expert highlights in August's newsletter.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

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