Monday to Today as Criteria in Query

E

E. Berhold

How do I create a function that calculates the date for moday this week? or
any week? to use as criteria in a query "Example [SomeDate] Between
thisMondaysDate and Date()" how do I get thisMondaysDate???
 
K

Ken Snell [MVP]

Try this function:


Public Function DateOfSpecificWeekDay(ByVal OriginalDate As Date, _
ByVal intWeekDay As Integer) As Date
' ** THIS FUNCTION RETURNS THE DATE OF THE SPECIFIC DAY OF THE WEEK
' ** IN WHICH THE ORIGINAL DATE IS.
' ** intWeekDay = 1 is Sunday, 2 is Monday, etc.

On Error Resume Next

DateOfSpecificWeekDay = DateAdd("d", -DatePart("w", OriginalDate, _
1) + intWeekDay, OriginalDate)
Err.Clear
End Function
 
Top