Query to select last weeks record based on this week's Monday date

baba

Registered User.
Local time
Yesterday, 17:54
Joined
Nov 15, 2011
Messages
39
I would like to select records that
are between last week's Monday and Sunday .I should be able to run it during any day of this week.
Is it possible to get a query that does Something like below
Select * from table where (This Week's Monday date - Table.RecordDate) < 8 ;
 
Add the two user defined public functions to a new module:
Code:
Public Function PrevSunday() As Date
     'returns the date of the Sunday prior to the current date
     PrevSunday = DateAdd("d", -DatePart("w", Date) + 1, Date)
End Function
Public Function PriorMonday() As Date
     'returns the date of the Monday prior to the Sunday prior to the current date
     PriorMonday = DateAdd("d", -6, DateAdd("d", -DatePart("w", Date) + 1, Date))
End Function

The use the following statement in the criteria of your date field in your query:

Code:
Between PriorMonday() And PrevSunday()
 

Users who are viewing this thread

Back
Top Bottom