Attention: We are retiring the ASP.NET Community Blogs. Learn more >

How To: Get Start Date and End Date of the Week

'Enter any Date in MDY format 
Dim dtNow As DateTime = Date.Parse("04/25/2004") 
Dim nowdayofweek As Integer = dtNow.DayOfWeek 
Dim weekStartDate, weekEndDate As DateTime 
weekStartDate = DateAdd("d", 0 - dtNow.DayOfWeek, dtNow) 
weekEndDate = DateAdd("d", 6 - dtNow.DayOfWeek, dtNow) 
'Displays first day of the week 
Response.Write(weekStartDate.ToString("MM/dd/yyyy")) 
'Displays last day of the week 
Response.Write("<BR>" & weekEndDate.ToString("MM/dd/yyyy")) 

No Comments