Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select records by time frame

Status
Not open for further replies.

sfullergs

IS-IT--Management
Nov 10, 2019
1
US
I have a field named lwmain.dtrepor that has date and time in the same field. Basically, I need to select records for my report based on A) the year and B) the time frame of 10:00:00 PM - 2:00:00 AM (those times are also how the database formats the times) each day. So, for example, I need it to pull records for each day in 2018 but only records between 10:00:00 PM - 2:00:00 AM each day. I have other criteria already entered to further narrow the results. How would it be possible to do this? I am totally stuck. Thanks!
 
Assuming the field is a datetime field, you should be able to use:

(
Year({yourfield})={?Year} and
(
Time({yourfield})>= time(22,0,0) or
Time {{yourfield})< time(2,0,1) //Change the 1 to zero if you don’t want to include 2:00
)
)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top