Week start calculation (1 Viewer)

Status
Not open for further replies.

namliam

The Mailman - AWF VIP
Local time
Today, 01:56
Joined
Aug 11, 2003
Messages
11,695
I was unable to find a weekstart calculation function, so I made one for this thread
http://www.access-programmers.co.uk/forums/showthread.php?p=697261&posted=1#post697261

Maybe it is an idea to put this function in here as Code Repo?
Code:
Function WeekStart(intWeekNR As Integer, intYear As Integer) As Date
    Dim dtMondayWk1 As Date
    Dim dtJan1st As Date
    Dim intWeekday As Integer
    dtJan1st = DateSerial(intYear, 1, 1)
    intWeekday = vbMonday ' Week startday, use vbSunday for sunday
    ' Default for "week1"
    dtMondayWk1 = dtJan1st - Weekday(dtJan1st, intWeekday) + 1
    If Format(dtJan1st, "WW") <> "1" Then
        dtMondayWk1 = dtMondayWk1 + 7
    End If
    WeekStart = dtMondayWk1 + (intWeekNR - 1) * 7
End Function
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom