Link to home
Start Free TrialLog in
Avatar of FCapo

asked on Monthcalendar dates


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.

Basically the week that includes todays date.
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
*No Points*

Proof of concept using Fernando's recommendation:
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())
	End Sub
End Module

Open in new window

Produces the following output -User generated image-saige-