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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Time Query 1

Status
Not open for further replies.

mlabac

Programmer
Jan 22, 2004
23
US
I am trying to create a query that will return records by a given date and time range. The query thus far is as follows:

SELECT DISTINCT Orders.ApprovalDate
FROM Orders
WHERE Orders.ApprovalDate Between #11/21/2004 15:0:0# And #11/22/2004 14:59:59#)

This works just fine. The problem is I want to run this query daily with out any parameters so it will return records with an approval date between 2 days prior, after 3pm and 1 day prior, up to 2:59. As above...I would run that query on the 23rd...at any time during the day.

Thoughts?
 
try DateAdd

Code:
Between CDate(DateAdd("d",-2,Date()) & " 3:00:00 PM") And CDate(DateAdd("d",-1,Date()) & " 2:59:59 PM")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top