Re: Search Date and Time
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Mon, 28 Jul 2008 21:19:01 -0400
No. That is why we usually recommend storing both date and time in a single
Date/Time field.
If you have some reason not to be able to comfine them, you will need to use
compound criteria for both fields. This will be easier to demonstrate using
sql, so switch your query to SQL View using the View menu, or the toolbar
button, or the right-click context menu. Assuming DateField and TimeField
are both Date/Time fields, the WHERE clause should look something like this:
WHERE (DateField = #7/23/2008# AND timeField >= 6:00:00 PM#)
OR
(DateField = #7/24/2008# AND timeField <= 6:00:00 AM#)
Floyd Forbes wrote:
How do I get this to work if date is in one column and time in another
column?
Can I still use the same expression?
Thank you
"John W. Vinson/MVP" <please.reply@xxxxxxxxxxxxxxxx> wrote in message
news:81qs84hp0cq2797s0vg1mc2v6q3fm5h7iv@xxxxxxxxxx
On Mon, 28 Jul 2008 20:32:51 -0400, "Floyd Forbes"
<newsgroups@xxxxxxxxxx> wrote:
How do you query between dates and times in access? I am trying to
query between #7/23/2008 6:00:00 PM# and #7/24/2008 6:00:00 AM# .
How do I get this to work? Please Help!
Floyd
Ummm....
You answered your own question.
Use a criterion on the datefield of
between #7/23/2008 6:00:00 PM# and #7/24/2008 6:00:00 AM#
Or, equivalently,
= #7/23/2008 6:00:00 PM# and <= #7/24/2008 6:00:00 AM#
Or for more flexibility,
BETWEEN [Forms]![SomeFormName]![txtStartTime] AND
[Forms]![SomeFormName]![txtEndTime]
to use unbound form controls of those names to enter the criteria.
--
John W. Vinson/MVP
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- Follow-Ups:
- Re: Search Date and Time
- From: Bob Barrows [MVP]
- Re: Search Date and Time
- References:
- Search Date and Time
- From: Floyd Forbes
- Re: Search Date and Time
- From: John W . Vinson/MVP
- Re: Search Date and Time
- From: Floyd Forbes
- Search Date and Time
- Prev by Date: Re: Search Date and Time
- Next by Date: Re: Search Date and Time
- Previous by thread: Re: Search Date and Time
- Next by thread: Re: Search Date and Time
- Index(es):