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

Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 712
Given a date like "9/23/2016", find the first 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 firstDayOfweek = initialDate.AddDays(CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek - initialDate.DayOfWeek);



Comments or Responses

Login to post response