View Full Version : Create a query to display records for this week


gazdobson
10-28-2009, 07:34 AM
I am designing a database in access to create a delivery list. The user will entre the delivery date into database as part of a record but I want to create a few queries. 1 that display all enteries for this week (Monday to Sunday), 1 for next week, and one for last week.

I have tried ideas such as
IIf(Weekday(Date()=4),[Del Date] Between Date()-2 And Date()+4,0)
For wednesday, would add IIF(Weekday(Date()=3) etc if worked but it didn't.


Any help will be much appreciated.

Regards

namliam
10-28-2009, 07:39 AM
Weekday(date()) returns the weekday, not the date(), thus your function should be something like
IIf(Weekday(Date())=4,...

If you just want the start of this week you will probably want something like:
Date() - Weekday(Date())

And welcome to AWF :)

gazdobson
10-28-2009, 08:06 AM
Thanks namlian,

"Between (Date()-Weekday(Date()-2)) And (Date()+(8-(Weekday(Date()))))" Seems to have done that job. :)

Regards

namliam
10-28-2009, 08:52 AM
Well done :)

FYI:
Lookup weekday in the access help, it has a second argument which allows you to set the "start of the week" to monday instead of (default) sunday.
That might make some more sense?!