Option Compare Database
Option Explicit
Dim myDate As Date
Public Function GetFirstDayOfWeek() As Date
Dim currDate As Date
Dim firstDay As Date
If Me.SmartDate = 0 Then
currDate = Date ' get current date
firstDay = currDate - (DatePart("w", currDate, vbMonday) - 1) ' calculate first day of week
ElseIf Me.SmartDate = 1 Then
currDate = Me.DateSelecter ' get current date
firstDay = currDate - (DatePart("w", currDate, vbMonday) - 1) ' calculate first day of week
End If
GetFirstDayOfWeek = firstDay
End Function
---------------------------------------------------------------------------------------
Function NameDayOfWeek(nDate As Date) As String
Dim NumDay As Integer
Dim StrDay As String
Dim dt As Date
Dim firstDay As Date
Dim firstDayWeek As Date
firstDayWeek = Weekday(nDate, vbMonday)
NumDay = Weekday(nDate, vbMonday)
Select Case NumDay
Case 1
StrDay = 1
Case 2
StrDay = 2
Case 3
StrDay = 3
Case 4
StrDay = 4
Case 5
StrDay = 5
Case 6
StrDay = 6
Case 7
StrDay = 7
Case Else
StrDay = 8
End Select
NameDayOfWeek = StrDay
End Function