Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Failed to convert parameter value from a String to a DateTime.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi... All

i am  trying to create xml file using edi file, am using econnect inferace in MS Dynamic GP,

through my code i creted xml file but wen the control goes to this line 

 string custid = eConcall.CreateTransactionEntity(connStr, custdocument);

It is giving error like :

Microsoft.Dynamics.GP.eConnect.eConnectException: Failed to convert parameter va

lue from a String to a DateTime.

*This post is locked for comments

  • Peter Muchira Profile Picture
    Peter Muchira 1,912 on at
    RE: Failed to convert parameter value from a String to a DateTime.

    Hello Fazil,

    You are welcome. Kindly mark it as an answer, to assist others who may search for the same issue.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Failed to convert parameter value from a String to a DateTime.

    Thats it. Setting up econnect service account solved the problem. Thanks a TONN dear.

  • Peter Muchira Profile Picture
    Peter Muchira 1,912 on at
    RE: Failed to convert parameter value from a String to a DateTime.

    Hello Fazil,

    Also ensure that profile of the econnect service account has a date format that is consistent with the one your are using in the XML. Econnect seems to 'prefer' the MM-dd-yyyy. So just login to the profile of the service account (under which econnect services are running) and confirm the date format under Calendar settings.

  • Suggested answer
    John Lowther Profile Picture
    John Lowther 5,122 on at
    RE: Failed to convert parameter value from a String to a DateTime.

    Hey Fazil,

    I do believe that David is on the right track, and that the problem is the different ways that the date can be formatted depending on various settings; however, in my humble opinion, I would try using an explicit conversion using the SQL Convert function on the field in the eConnect "Pre" procedure.
    It is also possible that you may even need to convert the field from the starting string to a DateTime,  and then back to a string to end up with it in the correct regional settings format.
    Yes, that's a double convert, but I have run into some places where that was the only way to get it to work and if it works, it works. :)

    You can find lots of information on the various parameters of the Convert function on this MSDN page.

    Hope this gets you headed in the right direction, and let me know how it goes.

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,965 Most Valuable Professional on at
    RE: Failed to convert parameter value from a String to a DateTime.

    Please check your Time regional settings.

    Are you using 24 hour or 12 hour time?

    If using 12 hour time, what are the suffixes you are using for morning and afternoon. Only am, pm, AM, PM are supported by SQL.

    David

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Failed to convert parameter value from a String to a DateTime.

    But how can i use this with econnect. its reading date from the xml document.

    I am trying to run the econnect sample for salesorder entry.

    the date format in regional settings is MM-dd-yyyy.

    and in the XML file also it is the same.

    Also get the same error when i run the 'Directdocumentsenderdotnet' sample from the econnect. Here i am directly using an xml document. i tried changing to many date formats in the xml failed.

    "Microsoft.Dynamics.GP.eConnect.eConnectException: Failed to convert parameter value from a String to a DateTime."

  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,965 Most Valuable Professional on at
    RE: Failed to convert parameter value from a String to a DateTime.

    I would suggest having a look at this post I wrote.

    blogs.msdn.microsoft.com/.../quick-tip-passing-date-and-time-variables-to-sql-server

    It also mentions an issue when the Time suffixes have been changed from AM and PM to A.M. and P.M.  SQL Server cannot handle the suffixes with the dots/periods. Check your regional settings.

    David

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Failed to convert parameter value from a String to a DateTime.

    Did got a solution?

    I have the same issue here :(... 

  • Suggested answer
    John Lowther Profile Picture
    John Lowther 5,122 on at
    Re: Failed to convert parameter value from a String to a DateTime.

    First I will admit that I do not use eConnect, however, I do import several MySQL database tables to MSSQL databases for data warehousing. And in that process I see this error quite a lot. It is just about always caused when a string that is supposed to be a date is not actually a valid date. For example 09/31/2011 is not a valid date as September does not have 31 days and when trying to import this into MSSQL this is the error I get.

    With all that said, try looking through your XML file specifically at the fields that are supposed to be Dates.  My bet is that one of them is either empty and thus should be 01/01/1900 or one of them is not a valid date.

    Hope this helps,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans