Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here how <a href="http://msdn.microsoft.com/en-us/library/xhz1w05e.aspx" rel="nofollow"><code>Convert.ToDateTime</code></a> method looks like when you decompile it;</p> <pre><code>public static DateTime ToDateTime(string value) { if (value == null) return new DateTime(0L); else return DateTime.Parse(value, (IFormatProvider) CultureInfo.CurrentCulture); } </code></pre> <p>As you can see, this method use <a href="http://msdn.microsoft.com/en-us/library/System.DateTime.Parse.aspx" rel="nofollow"><code>DateTime.Parse</code></a> method with your <a href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.currentculture.aspx" rel="nofollow"><code>CurrentCulture</code></a>. And if your string doesn't match your current culture date format, your code will be broken. That's the reason you get this error.</p> <p>Use <a href="http://msdn.microsoft.com/en-us/library/System.DateTime.ParseExact.aspx" rel="nofollow"><code>DateTime.ParseExact</code></a> with <code>"dd/M/yy hh:mm:ss:tt"</code> format instead.</p> <blockquote> <p>Converts the specified string representation of a date and time to its DateTime equivalent. The format of the string representation must match a specified format exactly or an exception is thrown.</p> </blockquote> <pre><code>string s = "23/8/11 01:33:01:PM"; DateTime newdate = DateTime.ParseExact(s, "dd/M/yy hh:mm:ss:tt", CultureInfo.InvariantCulture); Console.WriteLine(newdate); </code></pre> <p>Output will be;</p> <pre><code>8/23/2011 1:33:01 PM </code></pre> <p>Here a <kbd><a href="http://ideone.com/TF4iMm" rel="nofollow">DEMO</a></kbd>.</p> <p>For your case;</p> <pre><code>DateTime newdate = DateTime.ParseExact(row[8].ToString(), "dd/M/yy hh:mm:ss:tt", CultureInfo.InvariantCulture); </code></pre> <p>For more informations, take a look;</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx" rel="nofollow"><strong>Custom Date and Time Format Strings</strong></a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload