[RESOLVED] [02/03] Weeks & Days
Hello again.
I have to make half weeks full weeks. So, basically what I've done with the help of the great jmcilhinney, is to get the specified number of days & weeks within a certain timeframe. Now, it produces a result saying I've got 9 weeks and 3 days (in that time period).
What I'd like to do, is to round up / down the weeks, meaning, I do not want a remaining day.
This is what I tried, but failed :blush:
Code:
Dim startDate As Date = dtSuggStartDate.Value
Dim endDate As Date = startDate.AddMonths(Months)
Dim interval As TimeSpan = endDate.Subtract(startDate)
Dim weeks As Integer = interval.Days \ 7
Dim days As Integer = interval.Days Mod 7
Select Case days
Case 1
days -= 1
Case 2
days -= 2
Case 3
days -= 3
Case 4
days += 3
weeks += 1
Case 5
days += 2
weeks += 1
Case 6
days += 1
weeks += 1
Case 7
days = 0
End Select
MessageBox.Show(String.Format("There are {0} weeks and {1} days between {2:d} and {3:d}", _
weeks, _
days, _
startDate, _
endDate))
But now it shows I have 10 weeks and 7 days, instead of just showing I've got 11 weeks
Can anyone help me out, please?