I am getting wrong calculation for the count of weeks.
I have two dropdown values.
First values : 31-2011 (Week & Year)
Second Values : 1-2013 (Week & Year)..
When i calculate the duration of these two, i am getting total Weeks as "104700".
Actually i am getting wrong duration for these values.
I need to get "75" weeks only.
Because, 31-2011 will have 52 weeks (for 2011 = 21 Weeks (31week -52week))
2012 = We will have 53 Weeks (so 21+53 Weeks)
2013 = will have 1 Week ( So, 22+53+1) = 75..
What is the problem in my code..? where i need to change.
See my code
Dim parts1 As String() = drpStweek.SelectedItem.ToString().Split("-")
Dim parts2 As String() = drpEdweek.SelectedItem.ToString().Split("-")
If Integer.TryParse(parts1(0), week1) AndAlso Integer.TryParse(parts1(1), year1) AndAlso Integer.TryParse(parts2(0), week2) AndAlso Integer.TryParse(parts2(1), year2) Then
If year1 <= year2 Then
If year1 = year2 Then
Duration = week2 - week1
Duration += (52 - week1) + week2
If year2 - year1 > 1 Then
Duration += (52 * year2 - year1)