Date Restrictor for last week

C

ChuckW

Hi,

I need to run a report for transactions that occured last
week. I run the report on Monday or Tuesday of every
week for the previous week which would be start on a
Monday and end on a Sunday. Is there a special date
restrictor that I could use?

Thanks,

Chuck
 
S

Sunny

Find enddate and startdate and use in your query

enddate =date- weekday(date,vbMonday)
startdate - enddate - 6
 
A

Alan Fisher

-----Original Message-----
Hi,

I need to run a report for transactions that occured last
week. I run the report on Monday or Tuesday of every
week for the previous week which would be start on a
Monday and end on a Sunday. Is there a special date
restrictor that I could use?

Thanks,

Chuck
.
Assuming you have a command button to print the report
you could put code in the On Click event of the button
like this:

Dim datFirstDayInWeek as Date
Dim datLastDayInWeek as Date


datFirstDayInWeek = Date()- Weekday(Date(), vbMonday) + 1
datLastDayInWeek = Date()- Weekday(Date(), vbMonday) + 7

then use the variables in a where statement to open the
report like this:

DoCmd.OpenReport "rptYourReport",,,"[YourDateField] >= " _
& "#" & datFirstDayOnWeek & "#" & " AND " _
& "[YourDateField] <= " & "#" datLastDayInWeek & "#"
 
J

John Vinson

Hi,

I need to run a report for transactions that occured last
week. I run the report on Monday or Tuesday of every
week for the previous week which would be start on a
Monday and end on a Sunday. Is there a special date
restrictor that I could use?

Thanks,

Chuck

BETWEEN DateAdd("d", -7-DatePart("w", Date()), Date()) AND
DateAdd("d", -1-DatePart("w", Date()), Date())

will do the trick...
 

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

Similar Threads


Top