Get Day Of week For Given Date.

Posted by Eswarreddy under C# category on | Points: 40 | Views : 2929
This method used to "Get Day of week for Given Date." eg. If Date is '23-01-2010', Then This method will retuns 'Saturday' as Day of week.

public string DayFromGivenDate(string date)
string day=""; // Day of Week for Given Date.
DateTime dt = new DateTime();
dt = DateTime.ParseExact(date, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture); // Assigning Given date to Date Time Object based Format / IFormatProvider. eg. date="23-01-2010";
day = dt.DayOfWeek.ToString(); // This Will retuns Day Of week. eg. if Date is 23-01-10, then day is 'Saturday'

return day;

Comments or Responses

Login to post response