Given any date, find the last date of the week in C#

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

using System;
using System.Globalization;

namespace ConsoleApplication2
class Program
static void Main(string[] args)
var initialDate = Convert.ToDateTime("9/23/2016");
var lastDayOfWeek = initialDate.AddDays(CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek - initialDate.DayOfWeek).AddDays(6);



Comments or Responses

Login to post response