<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://thomasfreudenberg.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx</link><description>If you're using DateTime.ParseExact with a custom format string including slashes, don't forget to escape them. After I've catched FormatExceptions several times, I've found this explanation : '/' is the default date separator defined in DateTimeFormatInfo</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#223231</link><pubDate>Mon, 05 Oct 2009 23:18:52 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:223231</guid><dc:creator>reedone816</dc:creator><description>&lt;p&gt;@Chris,&lt;/p&gt;
&lt;p&gt;just like the example, @&amp;quot;yyyy\/MM\/dd HH:mm&amp;quot;, exclude the second&lt;/p&gt;
&lt;p&gt;btw. in visual studio 2008, you don't need the escape anymore, so you just do it like this (in vb):&lt;/p&gt;
&lt;p&gt;dim getdate as date&lt;/p&gt;
&lt;p&gt;getdate=DateTime.ParseExact(&amp;quot;2004/05/31&amp;quot;, &amp;quot;yyyy/MM/dd&amp;quot;, Nothing)&lt;/p&gt;
&lt;p&gt;and you change the null to Nothing, otherwise it will generate error, and remember no space in &amp;quot;2004/05/31&amp;quot;&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=223231" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#220125</link><pubDate>Fri, 18 Sep 2009 13:16:28 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:220125</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;Hi ,&lt;/p&gt;
&lt;p&gt;I have a similar problem in that I am trying to find the correct datetime.parseexact format for the us 12 hour format e.g 9/14/2009 12:00:00 AM&lt;/p&gt;
&lt;p&gt;Do you know how i need to specify the format string to parse these?&lt;/p&gt;
&lt;p&gt;Any help is greatly appreciated.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=220125" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#219499</link><pubDate>Wed, 16 Sep 2009 20:08:14 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:219499</guid><dc:creator>Sabastesy</dc:creator><description>&lt;p&gt;nice&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=219499" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#217633</link><pubDate>Tue, 08 Sep 2009 08:59:58 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:217633</guid><dc:creator>Dani</dc:creator><description>&lt;p&gt;thanks. this solved my problem&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=217633" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#214031</link><pubDate>Tue, 25 Aug 2009 00:08:37 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:214031</guid><dc:creator>Robert</dc:creator><description>&lt;p&gt;Brilliant... Just what I was looking for to save me at the end of a long day...&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=214031" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#209632</link><pubDate>Thu, 30 Jul 2009 09:18:02 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:209632</guid><dc:creator>garfield</dc:creator><description>&lt;p&gt;Thank you..&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=209632" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#103730</link><pubDate>Thu, 14 Aug 2008 06:17:01 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:103730</guid><dc:creator>Thomas Freudenberg</dc:creator><description>&lt;p&gt;Mac, a) April has only 30 days, and b) your format string does not specify the seconds fraction. Following line works fine:&lt;/p&gt;
&lt;p&gt;DateTime parsedDate = DateTime.ParseExact(&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;quot;2008-05-31T13:20:00:000&amp;quot;,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;quot;yyyy-MM-ddTHH:mm:ss:fff&amp;quot;, null);&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=103730" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#103729</link><pubDate>Thu, 14 Aug 2008 05:42:40 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:103729</guid><dc:creator>Mac</dc:creator><description>&lt;p&gt;I am parsing &amp;quot;2008-04-31T13:20:00.000&amp;quot;&lt;/p&gt;
&lt;p&gt;Any idea what could be the format? i am using yyyy-MM-ddTHH:mm:ss but it does not work.&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=103729" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#76064</link><pubDate>Thu, 10 Jul 2008 15:11:14 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:76064</guid><dc:creator>Thomas Freudenberg</dc:creator><description>&lt;p&gt;That's correct, because the watch window calls .ToString() to display objects.&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=76064" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#76063</link><pubDate>Thu, 10 Jul 2008 15:07:05 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:76063</guid><dc:creator>NewP</dc:creator><description>&lt;p&gt;At my end dt = {7/10/2008 12:00:00 AM}&lt;/p&gt;
&lt;p&gt;right after I execute &lt;/p&gt;
&lt;p&gt;DateTime dt = DateTime.ParseExact(&amp;quot;2008-07-10&amp;quot;, @&amp;quot;yyyy-MM-dd&amp;quot;,null);&lt;/p&gt;
&lt;p&gt;in watch window. So ... what could it be?&lt;/p&gt;
&lt;p&gt;I am pulling my hair on this ...&lt;/p&gt;
&lt;p&gt;thanks ..I appreciate it.&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=76063" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#76055</link><pubDate>Thu, 10 Jul 2008 14:07:10 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:76055</guid><dc:creator>Thomas Freudenberg</dc:creator><description>&lt;p&gt;NewP, ParseExact works as expected. I tried &lt;/p&gt;
&lt;p&gt;DateTime dt = DateTime.ParseExact(&amp;quot;2008-07-10&amp;quot;, @&amp;quot;yyyy-MM-dd&amp;quot;,null);&lt;/p&gt;
&lt;p&gt;and dt has the correct values.&lt;/p&gt;
&lt;p&gt;I assume that you convert the DateTime object to a string accidentally, which will the default format (like dt.ToString())&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=76055" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#76049</link><pubDate>Thu, 10 Jul 2008 13:10:04 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:76049</guid><dc:creator>NewP</dc:creator><description>&lt;p&gt;I am not sure what I am doing wrong.&lt;/p&gt;
&lt;p&gt;I am putting value in a datatable. Column type is DateTime.&lt;/p&gt;
&lt;p&gt;nextRow[colIndex]= DateTime.ParseExact(&amp;quot;2008-07-10, @&amp;quot;yyyy-MM-dd&amp;quot;,null);&lt;/p&gt;
&lt;p&gt;It always puts value in default format. So the resultant date that I see looks like &amp;quot;07/10/2008 12:00:00 AM&amp;quot;&lt;/p&gt;
&lt;p&gt;I don't understand why.&lt;/p&gt;
&lt;p&gt;any ideas?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=76049" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#74653</link><pubDate>Wed, 25 Jun 2008 15:41:10 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:74653</guid><dc:creator>Mitoman</dc:creator><description>&lt;p&gt;I am trying to parse 200806251630 into date time, and i am kinda having problem with parsing it this way&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=74653" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#39842</link><pubDate>Fri, 14 Sep 2007 00:11:22 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:39842</guid><dc:creator>Rick</dc:creator><description>&lt;p&gt;Thanks man!!!! solve my problem too.... 10q&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=39842" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#22030</link><pubDate>Wed, 14 Feb 2007 11:30:41 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:22030</guid><dc:creator>Thomas Freudenberg</dc:creator><description>&lt;p&gt;Hato0be, it depends on your regional settings. For example on my machine I set the date separator to '-', so the code above throws a FormatException if the string to be parsed contains slashes.&lt;/p&gt;&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=22030" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#22029</link><pubDate>Wed, 14 Feb 2007 11:19:52 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:22029</guid><dc:creator>Hato0be</dc:creator><description>&lt;p&gt;..sorry, i mixed up the command, it was..&lt;/p&gt;
&lt;p&gt;DateTime.ParseExact(&amp;quot;14/02/2007&amp;quot;, &amp;quot;dd/MM/yyyy&amp;quot;, null);&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=22029" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#22028</link><pubDate>Wed, 14 Feb 2007 11:15:27 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:22028</guid><dc:creator>Hato0be</dc:creator><description>&lt;p&gt;For me, don't know why... but works fine and without escaping the slashes, the date was in other format but i think it's the same..&lt;/p&gt;
&lt;p&gt;i used this command:&lt;/p&gt;
&lt;p&gt;DateTime.ParseExact(&amp;quot;2004/05/31&amp;quot;, &amp;quot;dd/MM/yyyy&amp;quot;, null);&lt;/p&gt;
&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=22028" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#430</link><pubDate>Thu, 26 Aug 2004 06:03:00 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:430</guid><dc:creator>Anonymous</dc:creator><description>R U caught by M$ like a few others who don't blog anymore or what's going on Thoemmi?&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=430" width="1" height="1"&gt;</description></item><item><title>re: DateTime.ParseExact</title><link>http://thomasfreudenberg.com/blog/archive/2004/07/20/DateTime.ParseExact.aspx#429</link><pubDate>Fri, 06 Aug 2004 15:53:00 GMT</pubDate><guid isPermaLink="false">483d7ed9-aa38-4432-af18-89f61e4445bf:429</guid><dc:creator>Anonymous</dc:creator><description>Thanks a lot! this solved my datetime problem :-)&lt;img src="http://thomasfreudenberg.com/aggbug.aspx?PostID=429" width="1" height="1"&gt;</description></item></channel></rss>