Query Previous Week Records

M

Michel Walsh

BETWEEN Date()-DatePart("w", date()) -6 AND Date()-DatePart("w", date())



That assumes:
- first day of the week if Sunday
- the field you use to compare does NOT have a time value (other that
00:00:00 )



Note that Date() - DatePart("w", date()) returns you the previous
Saturday (if vbSunday is the first day of the week), so, removing 6 days to
it returns the Sunday of the same week.



Note that the week number brings problem near the year change, since week 1
may complete or may succeed to week 52 or 53 or 54 of previous year, so that
is why I didn't use a approach based on it.




Vanderghast, Access MVP
 
S

Scott

Worked great, thank you!

Michel Walsh said:
BETWEEN Date()-DatePart("w", date()) -6 AND Date()-DatePart("w", date())



That assumes:
- first day of the week if Sunday
- the field you use to compare does NOT have a time value (other that
00:00:00 )



Note that Date() - DatePart("w", date()) returns you the previous
Saturday (if vbSunday is the first day of the week), so, removing 6 days to
it returns the Sunday of the same week.



Note that the week number brings problem near the year change, since week 1
may complete or may succeed to week 52 or 53 or 54 of previous year, so that
is why I didn't use a approach based on it.




Vanderghast, Access MVP
 

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

Top