Given any date, find the first date of the week in

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 50
Given a date like "9/23/2016", find the first date of the week. The below code will do so

Imports System.Globalization

Namespace ConsoleApplication2
Class Program
Private Shared Sub Main(args As String())
Dim initialDate = Convert.ToDateTime("9/23/2016")

Dim firstDayOfweek = initialDate.AddDays(CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek - initialDate.DayOfWeek)

End Sub

End Class
End Namespace

Comments or Responses

Login to post response