4 Replies Latest reply: Feb 23, 2011 10:05 AM by kamba dasan RSS

String was not recognized as valid DateTime error

kamba dasan
Currently Being Moderated

hi People,

          we are installing an addon which was designed in asp.net....its working fine in local machine but when we are running the addon in external machine which is microsoft server 2003 X86 bit it displays the error while processing the record.....

the error is "String was not recognized as valid DateTime".......tell me the solution for this..........

  • Re: String was not recognized as valid DateTime error
    James Michael
    Currently Being Moderated

    The local date settings on the server machine must be different to the ones on your local machine, so when it tries to parse the date using your logic, it cant.

     

    Uou can verify if this is the issue by going to Control Panel -> Region & Language. You will most likely see your date format is different to server?

     

    If it is the issue, you will need to use some .NET libraries to handle the issue of different date formats.

    • Re: String was not recognized as valid DateTime error
      kamba dasan
      Currently Being Moderated

      hi,

        we r not able to map the date format between sap b1 client and server machine......The date format which was given in the addon whether it should map server machine's date or sap b1 client Company's date......we r using SAP B1 8.8 PL13

      • Re: String was not recognized as valid DateTime error
        James Michael
        Currently Being Moderated

        Think of it like this:

         

        The SQL server has one date format, and when a document is added, it is added through SQL using that date format & B1 has a date format where date fields store the string as YYYYMMDD

        You addon runs on a client machine & therefore inherits the client machines date format. If you have hardcoded any date conversion into your addon, it will not work the same on machines which have different local settings.

         

        The fact it works well on one machine and not on another indicates that it probably has something to do with the actual format of the date.

         

        There are two useful tips with the DateTime library:

        Try using the ParseExact method of the DateTime object, this allows you to tell it what format you are receving the date in:

        DateTime test = DateTime.ParseExact(date,"yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);

         

        Or if converting in the other direction, you can use arguments on the ToString method:

        oDoc.DocDate = DateTime.Now.ToString("yyyyMMdd");

         

  • Re: String was not recognized as valid DateTime error
    kamba dasan
    Currently Being Moderated

    Thank U guys

Actions