Here:
http://stackoverflow.com/questions/662379/calculate-date-from-week-number[
^] is an idea. You have to change the code to your needs.
[EDIT]
Your issue is quite interesting, so i decided to write the piece of code to resolve it.
Here is a definition of
TDateFromWeek
class:
Imports System.Globalization
Public Class TDateFromWeek
Private firstDayInMonth As Date
Private dFrom As Date
Private dTo As Date
Public Sub New(ByVal yr As Integer, ByVal mh As Integer, ByVal weekno As Integer)
Dim wn As Integer = 0
firstDayInMonth = New Date(yr, mh, 1)
dFrom = firstDayInMonth
wn = GetWeekOfMonth(dFrom) - GetWeekOfMonth(firstDayInMonth) + 1
Do While (wn < weekno)
dFrom = dFrom.AddDays(1)
wn = GetWeekOfMonth(dFrom) - GetWeekOfMonth(firstDayInMonth) + 1
Loop
dTo = dFrom.AddDays(5)
End Sub
Public ReadOnly Property DateFrom As Date
Get
Return dFrom
End Get
End Property
Public ReadOnly Property DateTo As Date
Get
Return dTo
End Get
End Property
Private Function GetWeekOfMonth(ByVal currDate As Date) As Integer
Dim ci As CultureInfo = CultureInfo.CurrentCulture
Return ci.Calendar.GetWeekOfYear(currDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday)
End Function
End Class
Usage:
Dim dfw As TDateFromWeek = New TDateFromWeek(2015, 5, 2)
Console.WriteLine("{0} - {1}", dfw.DateFrom.ToString("yyyy-MM-dd"), dfw.DateTo.ToString("yyyy-MM-dd"))
Console.ReadKey()
Result:
2015-05-04 - 2015-05-09