How do I automatically return data from last two days?

W

waybomb

What would I use in the Criteria section of a querry that would return only
data from the last two days?
We ahve a small database of work orders for our maintenance department. One
of the automatic fields is "Date recieved" which I'd like to querry. I'd
like to keep a querry available to the maintenance team that allows them to
click on the querry, and without any other input, provide them a list of all
work orders recieved in the last 48 hours, or two days.
 
C

Chaim

SELECT * FROM [Your Table]
WHERE [Date Received] BETWEEN Date() AND Date() - 2;

Criteria would be

BETWEEN Date() AND Date() - 2

all on one line.

Good Luck!
 
J

John Vinson

What would I use in the Criteria section of a querry that would return only
data from the last two days?

For 48 hours, use
= DateAdd("h", -48, Now())

Add a criterion

AND < Now()

if you want to exclude data with future times.

For two calendar days (i.e. starting midnight at the beginning of day
before yesterday) use
= DateAdd("d", -2, Date())


John W. Vinson[MVP]
 

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