<p>Someone please correct me if I'm wrong, but parsing a yyyy/MM/dd (or other specific formats) dates in C# <strong>should</strong> be as easy as </p>

<pre><code>DateTime.ParseExact(theDate, "yyyy/MM/dd");
</code></pre>

<p>but no, C# forces you to create an IFormatProvider.</p>

<p>Is there an app.config friendly way of setting this so I don't need to do this each time?</p>

<pre><code>DateTime.ParseExact(theDate, "yyyy/MM/dd", new CultureInfo("en-CA", true));
</code></pre>

[{'answer_id': 64655, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 5, 'selected': True, 'text': '<p>The IFormatProvider argument can be null.</p>\n'}, {'answer_id': 64675, 'author': 'John Sheehan', 'author_id': 1786, 'author_profile': 'https://Stackoverflow.com/users/1786', 'pm_score': 2, 'selected': False, 'text': '<p>Create an extension method:</p>\n\n<pre><code>public static DateTime ParseExactDateTime(this string dateString, string formatString) {\n    return DateTime.ParseExact(dateString, formatString, new CultureInfo("en-CA", true));\n}\n</code></pre>\n'}, {'answer_id': 64701, 'author': 'David J. Sokol', 'author_id': 1390, 'author_profile': 'https://Stackoverflow.com/users/1390', 'pm_score': 3, 'selected': False, 'text': '<p>Use the current application culture:</p>\n\n<pre><code>DateTime.ParseExact("2008/12/05", "yyyy/MM/dd", System.Globalization.CultureInfo.CurrentCulture);\n</code></pre>\n\n<p>You can set the application culture in the app.config using the Globalization tag.  I think.</p>\n'}, {'answer_id': 64706, 'author': 'Jeff Hubbard', 'author_id': 8844, 'author_profile': 'https://Stackoverflow.com/users/8844', 'pm_score': 1, 'selected': False, 'text': '<p>You could also simply create the IFormatProvider once and store it for later use.</p>\n'}, {'answer_id': 64729, 'author': 'Xian', 'author_id': 4642, 'author_profile': 'https://Stackoverflow.com/users/4642', 'pm_score': 1, 'selected': False, 'text': '<p>You could also use the Convert class</p>\n\n<pre><code>Convert.ToDateTime("2008/11/25");\n</code></pre>\n'}, {'answer_id': 64744, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>ParseExact needs a culture : consider "yyyy MMM dd".  MMM will be a localized month name that uses the current culture.</p>\n'}, {'answer_id': 64757, 'author': 'Scott Dorman', 'author_id': 1559, 'author_profile': 'https://Stackoverflow.com/users/1559', 'pm_score': 2, 'selected': False, 'text': '<p>It requires the format provider in order to determine the particular date and time symbols and strings (such as names of the days of the week in a particular language). You can use a null, in which case the CultureInfo object that corresponds to the current culture is used.</p>\n\n<p>If you don\'t want to have to specify it each time, create an extension method which either passes null or CultureInfo("en-CA", true) as the format provider.</p>\n'}, {'answer_id': 421924, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>//Convert date to MySql compatible format</p>\n\n<p>DateTime DateValue = Convert.ToDateTime(datetimepicker.text);</p>\n\n<p>string datevalue = DateValue.ToString("yyyy-MM-dd");</p>\n'}, {'answer_id': 2365139, 'author': 'Nicholas Head', 'author_id': 22505, 'author_profile': 'https://Stackoverflow.com/users/22505', 'pm_score': 0, 'selected': False, 'text': "<p>What's wrong with using Globalization.CultureInfo.InvariantCulture ?</p>\n"}]
['https://Stackoverflow.com/questions/64640', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7311/']