How do I get my Query show only the last 5 days of data?

L

lennoux

I have a large database of data, I would like to only display the last week
of this info every week in a query or report?
 
J

John Vinson

In the Criteria of an appropriate Date field put something like

Between Date() -7 and Now()

Now if you need the last calendar week, it gets a little more complicated.
Something like below will almost work; however it will probably bomb out
during the first week of January.

SELECT tblDates.wa_date,
DatePart('ww',[wa_date]) AS TheWeek,
Year([wa_date]) AS TheYear
FROM tblDates
WHERE (((DatePart('ww',[wa_date]))=DatePart('ww',Date())-1)
AND ((Year([wa_date]))=Year(Date())));

It's a bit snarky, but you can get from Sunday before last through
last Saturday with a criterion
= DateAdd("d", -6-Weekday(Date()), Date()) AND < DateAdd("d", 1-Weekday(Date()), Date())

John W. Vinson[MVP]
 
Top