How do I automatically return data from last two days?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
WHERE [Date recieved] >= Date() - 2

What about Monday back to Friday? :D

--
Steve Clark, Access MVP
FMS, Inc.
Call us for all of your Access Development Needs!
1-888-220-6234
(e-mail address removed)
www.fmsinc.com/consulting
 
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!
 
Good question about Fri to Mon. I'll make the criteria -3.
I'm also giving the team a report where they can specify any date range.
This report I'm asking about would be a "quick report".
Thanks you - it works great!
Fred

[MVP] S.Clark said:
WHERE [Date recieved] >= Date() - 2

What about Monday back to Friday? :D

--
Steve Clark, Access MVP
FMS, Inc.
Call us for all of your Access Development Needs!
1-888-220-6234
(e-mail address removed)
www.fmsinc.com/consulting

waybomb said:
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.
 
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]
 
Back
Top