1. First, check that the date string is a valid one using tryparse;
2. Specify the desired date format;
3. then can do the conversion.
using System;
public class Program
{
public static void Main()
{
string dateString = "2/22/2014 5:08:46 PM";
Console.WriteLine("The original string is {0}", dateString);
DateTime dt;
if (DateTime.TryParse(dateString, out dt))
{
string format = "yyyy-MM-dd";
Console.WriteLine(dt.ToString(format));
}
else
{
Console.WriteLine("Not a valid datetime");
}
}
}