Find Date Range in

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 36
Given a date like "8/16/2016", find the next 7 days range. The below code will do so

Private Shared Function GetDateRange(startDt As DateTime) As List(Of DateTime)
Dim dtList As New List(Of DateTime)()
Enumerable.Range(0, 7).ToList().ForEach(Function(i) dtList.Add(startDt.AddDays(i)))
Return dtList
End Function

use like

Dim initialDate = Convert.ToDateTime("8/16/2016")
Dim dtRange = GetDateRange(initialDate)

Comments or Responses

Login to post response