7 Day Query

RustyRick

Registered User.
Local time
Yesterday, 17:49
Joined
Jan 31, 2013
Messages
123
I want to pull a report, including only the last 7 days not including today. How best should I do that?

What query syntax will pull those record out?
 
Set up your report without critera for the date. You can then open it using code like this:

DoCmd.OpenReport "ReportNameHere", acViewPreview, WhereCondition:="DateFieldHere Between #" & DateAdd("d", -7, Date()) & "# AND #" & Date() & "#"
 
Where do I put this code?
 
i think bob missed that you wanted to exclude today, as his range extracts dates for the last 7 days including today.

here is a slightly different approach.
if you have a query as the base of the report - then in the criteria for the date column you are testing put this

between date()-8 and date()-1

that should work. If your date column includes a time, as well as the date, then this will need further attention
 
Thanks for your interest in my project. This report needs to be run daily at the START of every day, hense there is no data for today yet.

between date()-8 and date()-1
However that just returns the last 2 days data. ??? I don't have time in the picture.

I'm trying to make it so that when the receptionist opens the report it runs without her having to type in the "Start Date" and "End Date". (EXCLUDING TODDAY)

That would save having to count back the 7 days of a calendar and then typing it in accurately.

So yes it needs, to query the last 7 days, NOT INCLUDING TODAY, as there is no data for today yet.
 

Users who are viewing this thread

Back
Top Bottom