I think that I have missed something quite elementary in my approach. I have two dates, I need to calculate the number of weeks between the dates, plus any left over days. For example StartDate - Thursday Oct 25 / EndDate Saturday November 3rd. There are 10 days between these dates. What I need is a formula that will return 1 week 3 days. I have tried quite a few variations on the theme below.
Dim SeasonStart As Date = dtpStart.Text, Dim SeasonEnd As Date = dtpend.Text
Dim iDay As DayOfWeek
Dim dWeek As Decimal
Dim m_percentage, m_wholeNum, full_string, m_array() As String
iDay = DateDiff(DateInterval.WeekOfYear, SeasonStart, SeasonEnd)
dWeek = Math.Round((iDay / 7), 1, MidpointRounding.AwayFromZero)
full_string = dWeek.ToString("#.#")
m_array = Split(full_string, ".")
m_percentage = m_array(0)
m_wholenum = m_array(1)
label1.text = m_wholeNum & " weeks and " & m_pecentage & " days"
I have a rounding problem in every way I have approached it. The next step in the process requires that I subtract a number of daysfrom the total number of days before I calculate weeks and months, so hopefully someone can suggest a method where I still have a number of days and then convert that to a number of weeks.
Any advice is, as always, greatly appreciated.