### Calculate Weekstart and Enddates

Example sub to calculate the Week Start and End Dates, with Monday as first day of the week.
'Calculate the weekstart and weekend date, being Monday the first day of the week
'Return array as long with 0=weekstart and 1=weekend date
'Example:
'Dim wl() As Long = WeekStartAndEnd(DateTime.DateParse("12.02.2016"))
'Dim ws As String = DateTime.Date(wl(0))
'Dim we As String = DateTime.Date(wl(1))
'Day=12.02.2016Weekstart=08.02.2016, Weekend=14.02.2016
`Sub WeekStartAndEnd(d As Long) As Long()
Dim firstDay As Int = 2 'Monday
Dim day As Int = DateTime.GetDayOfWeek(d)
Dim start As Long = DateTime.Add(d, 0, 0, -1 * (day - firstDay))
Return Array As Long(start, DateTime.Add(start, 0, 0, 7) - 1)
End Sub`

Changed: , Category: DateTime, File: T6C183M1320.htm, ID: 1320