Here's the solution for you:
Private Function GetPreviousMonday(ByVal dt As DateTime) As String
Dim intWeekday As DayOfWeek = dt.DayOfWeek
Dim intSubtract As Integer = 0
Select Case intWeekday
Case 0 ' Sunday
intSubtract = -6
Case 1 ' Monday
intSubtract = 0
Case 2 ' Tuesday
intSubtract = -1
Case 3 ' Wednesday
intSubtract = -2
Case 4 ' Thursday
intSubtract = -3
Case 5 ' Friday
intSubtract = -4
Case 6 ' Saturday
intSubtract = -5
Case Else
Return "Unable to get day of the week"
End Select
Return dt.AddDays(intSubtract).ToString("MM/dd/yyyy")
End Function
Usage:
MessageBox.Show(GetPreviousMonday(#5/4/2007#))
I hope this helps,
--
Newbie Coder
(It's just a name)
"Thammarat charoenchai." <ap****@gmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi, I'm wonder VB have som function to get First day of the week?
like I'm have
dim d1 as datetime=12/5/2007
d2 = firstweekday(d1) '=7/5/2007
thank you very much