Try this:
using System;
using System.Globalization;
public class Program
{
public static void Main()
{
string dateString = "01/01/2015";
string format = "dd/MM/yyyy";
DateTime aDate;
if (DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture,
DateTimeStyles.None, out aDate))
{
Console.WriteLine("The day of the week for {0} is {1}.", dateString, aDate.DayOfWeek);
}
}
}
1. use
DateTime.TryParseExact Method[
^] to parse the date string to a pre-determined datetime format.
2. use
DateTime.DayOfWeek Property[
^] to return the day of the week for that date.