String was not recognized as a valid DateTime. RRS feed

  • Question

  • User2104118281 posted


    Have just created a test website with the club starter kit.

    All looks good except when I try to view the events using Events_Calendar.aspx I get the error 'String was not recognized as a valid DateTime.'

    Any ideas what could be causing this?



    Friday, April 29, 2005 10:42 AM

All replies

  • User1586277400 posted
    I also get this error, and it's frustrating me. The error is occurring in EventCalendar.dll, which is a dll which ships with the solution in the bin folder. Yet there is no source code for this and I can't find it anywhere. Nor do I have access to a decompiler to decompile the code. Please MS can you include the EventCalendar project and source so we can diagnose and fix this problem.
    Sunday, May 1, 2005 9:11 PM
  • User1586277400 posted
    I tried decompiling this with the trial version of Spices.Net, but it cut out half of the methods (as it's the trial version). Error is occurring in the CreateDataBoundChildren method of EventCalendar, presumably on the line: dv.RowFilter = string.Format("{0}>= #{1}# AND {0} < #{2}#", DayField, dateTime1.ToString("MM/dd/yyyy"), dateTime2.ToString("MM/dd/yyyy")); Full stack trace: [FormatException: String was not recognized as a valid DateTime.] System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2136542 System.DateTime.Parse(String s, IFormatProvider provider) +26 System.Data.ConstNode..ctor(DataTable table, ValueType type, Object constant, Boolean fParseQuotes) +544 System.Data.ExpressionParser.Parse() +1168 System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +123 System.Data.DataView.set_RowFilter(String value) +172 ControlSample.EventCalendar.CreateDataBoundChildren(DataView dv, Table table, DateTime todaysDate, DateTime visibleDate, Calendar threadCalendar) +426 ControlSample.EventCalendar.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +220 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +58 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +25 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +119 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +68 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +61 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +67 System.Web.UI.Control.EnsureChildControls() +103 System.Web.UI.Control.PreRenderRecursiveInternal() +50 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6326
    Sunday, May 1, 2005 9:16 PM
  • User1416329745 posted

    String is not recognized as Datetime because String is a reference type and Datetime is a value type and the .NET Calendar class is in INT and a few Double.  I have seen someone recommend Stringbuilder for value types but I have not used it.  Try the link below for the Calendar class.  Hope this helps.


    Sunday, May 8, 2005 5:15 PM
  • User1572957409 posted

    i have not solved it, but i guess its a date format problem,

    i use a german OS which formats a dat like 30.12.2005

    US expect 12 / 30 / 2005


    Monday, May 16, 2005 12:47 PM
  • User1572957409 posted

    i have found a workaorund, not perfect but page is displayed

    explitly switch culture of this page to en-US

    <%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" Trace="false" Culture="en-US" %>

    Monday, May 16, 2005 12:52 PM
  • User1416329745 posted
    The Asp.net team have posted complete code you can use.  Try the link below.  Hope this helps.

    Saturday, May 28, 2005 4:05 PM
  • User422024807 posted

    Error indeed comes from Events_Calendar.dll.

    To solve the problem, I deleted this dll but included its source (CalendarDay.cs, DivCtrl.cs, EventCalendat.cs, ItemTemplates.cs) into the club project placed into App_Code directory. Debugger immedeatly indicated the source of the error. In EventCalandar.cs, line 256 I removed formatting "MM/dd/yy" from argument of d.ToString("MM/dd/yy").

    That's all.

    Monday, May 30, 2005 6:23 AM
  • User580314607 posted
    If anyone wants the recompiled eventscalender to work with uk dates mail me (nospam_james.clark@btinternet.com) remove the nospam_ 

    I might take a day to respond but will send.

    Saturday, September 17, 2005 4:52 PM
  • User629187976 posted

    Hello, I think I’ve found de solution for Localize EventCalendar.dll in Spanish (European) date format.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    <o:p> </o:p>

    Just change MM/dd/yyyy for dd/MM/ yyyy in the source code of EventCalendar.dll available in this forums… Anyway I am going to make the file public.<o:p></o:p>

    <o:p> </o:p>

    Best Regards<o:p></o:p>

    <o:p> </o:p>

    Monday, September 19, 2005 6:46 AM
  • User1519746945 posted
    there has to be another way to switch from one language to the other for the WHOLE project, even for ALL projects on the webserver... had 2 projects running without any problems for about 2 years , but now, i think it has something to do with the .NET 1.1 update i have done, they have switched language and the result is 2 not workin webapps...

    any ideas!?

    Friday, December 2, 2005 3:42 AM
  • User-479017474 posted

    Hi, preishuber,

    the Culture="en-US" works on me. I am using at new zealand , and my test server at US, so i just add the line in my page and work fine on the server.


    Sunday, February 11, 2007 6:02 PM
  • User-80939892 posted


    In general I have found over the years that working with date and time has presented a varity of challenges. When converting from strings with asp.net I have found this simple example to provide reliable results...<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    Dim sBirthDate As String = BirthDate.Text & ""
    If IsDate(sBirthDate) Then
        Dim dBirthDate As Date = Date.Parse(sBirthDate)
    Dim dBirthDate As Date = Date.Parse("1/1/1970") 'default
    End If


    Wednesday, February 14, 2007 10:54 PM
  • User1610544847 posted

    Does anyone have this version of the dll or know where I can get the code for VS 2005?

    Tuesday, June 12, 2007 4:31 AM
  • User379672830 posted

    hi i too faced the same problem and i solved the problem.I just changed  System Globalization .

    For more details





    Thursday, November 22, 2007 11:55 PM
  • User2020557925 posted

    Thankyou that works great for me. Cool

    Friday, July 24, 2009 6:04 AM