Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

Last post 11-16-2007 2:14 PM by ounlopez. 11 replies.

Sort Posts:

  • Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    12-22-2006, 3:34 PM
    • Member
      point Member
    • database
    • Member since 12-22-2006, 8:22 PM
    • Posts 5
    i am facing a problem when i access one of the pages. it used to work before but after restarting the application sever it gives the following error.

    Server Error

    --------------------------------------------------------------------------------
    The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [FormatException: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.]

    System.DateTimeParse.Lex(Int32 dps, __DTString str, DateTimeToken dtok, DateTimeRawInfo raw, DateTimeResult result, DateTimeFormatInfo& dtfi) +1658
    System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +334
    System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) +30
    System.DateTime.Parse(String s, IFormatProvider provider) +11
    System.Convert.ToDateTime(String value, IFormatProvider provider) +61
    WebDateTime.clsWebDateTime.set_Text(String value)
    WebDateTime.clsWebDateTime.set_Value(String value)
    System.Web.UI.Contro



    i tried to change the regional setting and restart the server but the problem still there.
    i changed it to dd/mm/yyyy and hh:mm:ss tt as before.

    please advise me as i need the solution for urgent.
  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    12-23-2006, 12:49 AM
    • Star
      9,676 point Star
    • pickyh3d
    • Member since 09-17-2002, 10:19 AM
    • Virginia
    • Posts 1,955
    May we see the offending code?
    Picky
  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    12-23-2006, 6:56 AM
    • Member
      point Member
    • database
    • Member since 12-22-2006, 8:22 PM
    • Posts 5

    Actually, I do not have the access to the code.

    However, as I said, the page is used to work. But after restating the application server due to a low memory; this page stop to be displayed because of the error above. All I have is the stack trace.

     

    I believe that the problem in the server data time configuration.

     

  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    12-23-2006, 1:15 PM
    • Star
      9,676 point Star
    • pickyh3d
    • Member since 09-17-2002, 10:19 AM
    • Virginia
    • Posts 1,955
    Can you post the line from the config file then with the format string?
    Picky
  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    12-24-2006, 1:26 AM
    • Member
      point Member
    • database
    • Member since 12-22-2006, 8:22 PM
    • Posts 5

    <globalization requestEncoding="utf-8" responseEncoding="utf-8"/> this line from web.config

    and the sting format that is used is dd/mm/yyyy

  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    12-31-2006, 4:45 PM
    • Member
      point Member
    • database
    • Member since 12-22-2006, 8:22 PM
    • Posts 5

    Any idea regarding this issue??

  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    12-31-2006, 9:45 PM
    • Star
      9,676 point Star
    • pickyh3d
    • Member since 09-17-2002, 10:19 AM
    • Virginia
    • Posts 1,955
    Can your copy paste the exact line(s) where ever your datetime format string is being entered?
    Picky
  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    01-03-2007, 3:40 AM
    • Member
      point Member
    • database
    • Member since 12-22-2006, 8:22 PM
    • Posts 5

    in the page that i am trying to dispaly has no datetime entry. but what i found in the log that there is only an insert statmet that include the date and time.

    SELECT SQ.NEXTVAL FROM dual
    INSERT INTO AD_AUDIT_RECORDS ( ACTION_ID,RECORD_ID,FORM_ID,USER_ID,AT_DATE,AT_TIME,AT_ACTION,AT_KEY )VALUES(3871,256,18,1,TO_DATE('03/01/2006','dd/mm/yyyy'),'11:44 AM','View','USER_ID = 700001' )

  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    01-04-2007, 5:20 PM
    • Star
      9,676 point Star
    • pickyh3d
    • Member since 09-17-2002, 10:19 AM
    • Virginia
    • Posts 1,955

    You can change the time to military time (for the database since you said you're not displaying anything) by changing the date/time format string to "t" for just the hours and minutes (e.g., "20:13" for 8:13 PM) and "T" for the hours, minutes, and seconds (e.g., "20:13:54" for 8:13:54 PM).

    I don't know that this SQL query is actually the problem because it's not even using your time's timestamp (hh:mm:ss tt, which would be "03:04:01 AM" and "04:33:21 PM" [I showed both to point out the leading zeros and the fact that it uses 01 - 12 hours instead of 0 - 23 hours]), which I noticed because the query does not use have the seconds portion of your timestamp.  I'd guess the timestamp being used is "hh:mm tt" or maybe just "h:m tt" -- there are no leading zeros in the supplied time to be able to tell which is used.

     

    Picky
  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    03-08-2007, 7:12 PM
    • Member
      135 point Member
    • ounlopez
    • Member since 10-06-2006, 3:51 PM
    • Posts 41

    Was this problem ever solved? I am having a similar problem, and not sure where in my script it is ocurring.

    Any ideas?

    Thanks,

    Oun

  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    08-09-2007, 10:32 AM
    • Member
      4 point Member
    • PeterW
    • Member since 08-09-2007, 2:27 PM
    • Posts 2

    The format of DateTimes is covered in C# docs under custom DateTime formats. This defines what characters are used to determine what output. You state dd/mm/yyyy is the format specifier

    I would guess that when referring to months you not use mm but instead MM.  mm means minutes and MM means numeric month with a leading 0 if needed to ensure 2 digits are used.  Try dd/MM/yyyy.

    I could be wrong but that would be my stab at it.

  • Re: Error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 20.

    11-16-2007, 2:14 PM
    • Member
      135 point Member
    • ounlopez
    • Member since 10-06-2006, 3:51 PM
    • Posts 41

    Unfortunately, this did not do it. I really do not understand this problem. 

Page 1 of 1 (12 items)