Some companies use week of year instead of month for keeping record. So, what is the first day of Week 15 in 2008? What is the week of year of 15 Feb 2008? Here are two
helper functions:
Public Function WeekOfYear(ByVal d As Date) As Integer
Return DateDiff(DateInterval.WeekOfYear, CDate("1 Jan " & d.Year.ToString), d) + 1
End Function
Public Function StartDateOfWeekOfYear(ByVal weekOfYear As Integer, ByVal Year As Integer) As Date
If weekOfYear < 1 OrElse weekOfYear > 53 Then
Throw New ApplicationException("Invalid Week Of Year")
End If
Dim d As Date = CDate("1 Jan " & Year.ToString)
If weekOfYear = 1 Then
Return d
Else
Return d.AddDays(((weekOfYear - 1) * 7) - d.DayOfWeek)
End If
End Function