I have a function that throws me the current week of the year where we are now, thanks to one of the answers in this forum .
Well, but now I need is that of the same week can get the initial date of that week and the final.
¿How could accomplish this?
Protected Friend Function obtenerNumeroSemanas(ByVal dt As DateTime)
Dim cal As Calendar = CultureInfo.InvariantCulture.Calendar
Dim d As DayOfWeek = cal.GetDayOfWeek(dt)
If (d >= DayOfWeek.Monday) AndAlso (d <= DayOfWeek.Wednesday) Then
dt = dt.AddDays(3)
Return cal.GetWeekOfYear(dt, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
Dim dayOfWeek = Cint(DateTime.Today.DayOfWeek) Dim startOfWeek = DateTime.Today.AddDays(-1 * dayOfWeek) Dim endOfWeek = DateTime.Today.AddDays(7 - dayOfWeek).AddSeconds(-1) Console.WriteLine(startOfWeek) Console.WriteLine(endOfWeek)
Using today's date (2016-06-19) results in
2016-06-19 12:00:00 AM 2016-06-25 11:59:59 PM