Applecore Pages on Microsoft Access

What is the next/previous Monday?

Two functions here, one to return the date of the next named day, and the other the previous named day:

Function fDateDayPrevious(dtmDate As Date, bytDaySought As Byte) As Date
'   Function to return the date of the named day previous to the passed date
'   Accepts:bytDaySought (e.g.: vbSunday)
'   dtmDate as date

    If bytDaySought - WeekDay(dtmDate) <= 0 Then
        fDateDayPrevious = dtmDate + bytDaySought - WeekDay(dtmDate)
    Else
        fDateDayPrevious = dtmDate + bytDaySought - WeekDay(dtmDate) - 7
    End If
End Function
 
Function fDateDayAfter(dtmDate As Date, bytDaySought As Byte) As Date
'   Function to return the date of the named day after the passed date
'   Accepts:dtmDate - any date
'   bytDaySought (e.g. vbMonday)

    If bytDaySought - WeekDay(dtmDate) >= 0 Then
        fDateDayAfter = dtmDate + bytDaySought - WeekDay(dtmDate)
    Else
        fDateDayAfter = dtmDate + bytDaySought - WeekDay(dtmDate) + 7
    End If
End Function

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:54:30