By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,568 Members | 1,688 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,568 IT Pros & Developers. It's quick & easy.

Date Queries

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.