Query to select a range of time, based on a single time

J

JWCrosby

I have a time field (like 1:30 PM) indicating a student's performance time.
I want to write a query that will select all the students who have been
assigned to perform at the same time (i.e., 1:30 PM) as well as all the
students assigned to perform during the time period from 60 minutes before to
60 minutes after.

In other words, based on the single field of 1:30 PM I want to select all
the records with a time between 12:30 PM and 2:30 PM.

Of course, the single time isn't always 1:30 PM but I can adapt anything
someone comes up with to help me.

Thanks in advance.

Jerry
 
D

Duane Hookom

You can use the DateAdd() function to add or subtract a number of date/time
intervals from a date/time values. For instance you can find 60 minutes
earlier than a datetime value with:
DateAdd("n",-60,[OriginalTime])
 
J

JWCrosby

Thanks so much, Duane. It did the trick!
Jerry

Duane Hookom said:
You can use the DateAdd() function to add or subtract a number of date/time
intervals from a date/time values. For instance you can find 60 minutes
earlier than a datetime value with:
DateAdd("n",-60,[OriginalTime])
--
Duane Hookom
MS Access MVP

JWCrosby said:
I have a time field (like 1:30 PM) indicating a student's performance time.
I want to write a query that will select all the students who have been
assigned to perform at the same time (i.e., 1:30 PM) as well as all the
students assigned to perform during the time period from 60 minutes before
to
60 minutes after.

In other words, based on the single field of 1:30 PM I want to select all
the records with a time between 12:30 PM and 2:30 PM.

Of course, the single time isn't always 1:30 PM but I can adapt anything
someone comes up with to help me.

Thanks in advance.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top