Is there a way to get the start and end date of the current week?
For example, today is the 7/31/2015, I'd like to get the start date of sunday (July 26), and then the end date of saturday (August 1st) from the calendar.
Module Module1 Sub Main() Dim now = DateTime.Now ' Get the current day of the week 0 - 6, 0 = Sunday and 6 = Saturday Dim current = now.DayOfWeek ' Get the start of the week by subtracting current day of week Dim start = New DateTime(now.Year, now.Month, now.Day).AddDays(-current) ' Get the end of the week by adding 6 to the start. Dim [end] = start.AddDays(6) Console.WriteLine("The first date of the week for {0} is {1}", now.ToShortDateString(), start.ToShortDateString()) Console.WriteLine("The last date of the week for {0} is {1}", now.ToShortDateString(), [end].ToShortDateString()) Console.ReadLine() End SubEnd Module
Proof of concept using Fernando's recommendation:
Open in new window
Produces the following output -