query for time only

L

Lisa

Is there a way to query for only the time portion of a
date/time field and ignore the date part?

I have a date/time field that I do not care what the given
date is, only want query results of if time is greater
than say 8:00 am and less than 3:00 pm.

Thanks!
 
K

Ken Snell [MVP]

Add a calculated field to your query that extracts the time portion of the
date/time field:

MyTime: TimeValue([NameOfDateTimeField])

Then put a criterion on this calculated field:

Between #8 am# And #3 pm#
 
P

PC Datasheet

If your criteria is always whole hours like in your example, enter the
following expression in a blank field in your query:
MyDesiredTime:DatePart("h",[NameOfdateTimeField])
and per your example, put the following in the criteria:
Between 8 And 15
 
Top