473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Date Queries

I have a table with two fields, 'StartDate' and 'EndDate'. How do I
get the query to select a record that matches a given date that is
between the two dates?
Nov 13 '05 #1
4 2182
Colin Mardell wrote:
I have a table with two fields, 'StartDate' and 'EndDate'. How do I
get the query to select a record that matches a given date that is
between the two dates?


I'd bet upon

SELECT * FROM yourtable WHERE [enter date:] BETWEEN startdate AND enddate

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2
hmmm...

well... if you're thinking of retrieving one single record with your
query, well, unless you are sure you have one and only one record that
has this date value that falls between the startDate and endDate then
you'll be recieving more than one.

Also, knowing which database would help, but here is how I'd do it in
SQl Server 2000

select [someField] from [someTable] where ([dateField] > @startDate and
[dateField] < @endDate)
In Oracle we take advantage of the between keyword
select [someField] from [someTable] where ([dateField] BETWEEN
@startDate and @endDate)

*keep in mind that in Oracle, between includes the startDate and endDate
**@paramName is a parameter name that you pass on to the query.

cheers

got a code problem? hand it to the devil.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
Colin,

On the query grid, in the criteria for *both* fields, try this:

[EnterDate] Between [StartDate] And [EndDate]

When you run the query it will prompt you to enter a date and should
return records where the entered date is between the two.

HTH - Keith.
www.keithwilby.com

Colin Mardell wrote:
I have a table with two fields, 'StartDate' and 'EndDate'. How do I
get the query to select a record that matches a given date that is
between the two dates?

Nov 13 '05 #4
CodeDevil <Co*******@thedevils.com> wrote in
news:1102245849.ojdwXr8WrLrY+qlhjW8iUA@teranews:
In Oracle we take advantage of the between keyword
select [someField] from [someTable] where ([dateField] BETWEEN
@startDate and @endDate)

*keep in mind that in Oracle, between includes the startDate and endDate


The BETWEEN keyword does exist in both SQL Server and in Access, and
behaves the exact same way.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: BlackFireNova | last post by:
Using Access 2002 I am writing a report which draws data from several different tables. I can't link all the tables in a query, as some can not be related without truncating the data. I plan...
1
by: EnriqueM | last post by:
One question: I created an access database that has been extremely useful in my work. I dont' even know at what level of knowledge I am at. I read a lot about how to create a database, created many...
5
by: David B | last post by:
I have a number of queries, running one after the other, which do quite a complex calculation. A text box on a form provides the date for this routine. I have another routine I wish to do and it...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
10
by: Kenneth | last post by:
I have a Query that consist of a lot of different sales data, and one of the colums are different date. The date goes from 1jan2003 til 31jan2003. in this Query I only want the salesdata for...
2
by: carl.barrett | last post by:
Hi, I'm back with the same question as I still can't get it to display my data the way I want it to. The table lists information about a perpetrator involved with an anti social behaviour...
6
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by...
9
by: mharrison | last post by:
Hello, I am developing a small java web-based car-pool booking system app which interacts with an access database. I am trying to write 2 queries: The first which will specify whether a given car...
19
by: eskelies | last post by:
I have two queries. My goal is to pull a range of numbers that fall on or in a certain date range. For example, $100 on 9/1/2007 and $200 on 9/24/2007. I want the date range to pick up both the...
3
by: murch.alexander | last post by:
I made a simple public function to set and return a date value (see below). I have a number of queries that call up the function to get the "As Of Date," which is typically set to today's date....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.