// Parse date-only value with invariant culture. dateString = textBox1.Text; format = "u"; // or "s" try { result = DateTime.ParseExact(dateString, format, provider); } catch (FormatException) { Console.WriteLine("{0} is not in the correct format.", dateString); }