web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

The conversion of nvarchar data type to a datetime data type resulted in an out of range value.

(0) ShareShare
ReportReport
Posted on by 11,633

Hi All,

I was trying to process out of the box Production order cube, and getting this conversion error. When I pasted the SQL query which was producing this error in SQL management studio, I am able to reproduce the same error, then I select each column one by one in query window and found the same error when I used the following select statement:

select DaysDelayed from ProdTableExpanded.

DaysDelayed is a computed column in View ProdTableExpanded. After 134 rows, this error occurred and further rows were not returned.The code for computed column is shown below:

public static server str daysDelayed()

{

   TableName   viewName                = identifierStr(ProdTableExpanded);

   str         dlvDate                 = SysComputedColumn::comparisonField(viewName, identifierStr(ProdTable),fieldStr(ProdTable, DlvDate));

   str         finishedDate            = SysComputedColumn::comparisonField(viewName, identifierStr(ProdTable),fieldStr(ProdTable, FinishedDate));

   str         todayDate               = SysComputedColumn::comparisonLiteral(date2StrUsr(today(), DateFlags::None));

   str         prodStatusField         = SysComputedColumn::returnField(viewName, identifierStr(ProdTable),fieldStr(ProdTable, ProdStatus));

   Map         comparisonExpressionMap = SysComputedColumn::comparisionExpressionMap();

   comparisonExpressionMap.insert(

       SysComputedColumn::and2

       (

           SysComputedColumn::notEqualExpression(prodStatusField, SysComputedColumn::returnLiteral(5)),

           SysComputedColumn::notEqualExpression(prodStatusField, SysComputedColumn::returnLiteral(7))

       ),

       SysComputedColumn::getDateDiffWithFallbackToZero(dlvDate, todayDate)

   );

   return SysComputedColumn::switch('',

           comparisonExpressionMap,

           SysComputedColumn::getDateDiffWithFallbackToZero(dlvDate, finishedDate));

}

Does anyone have any idea how to fix this issue? I am really stuck in this issue and out of ideas.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    dolee Profile Picture
    11,279 on at

    Hi,

    The code for this method has changed in CU7 and no issue running that query against a CU7 ProdTableExpanded. You can either do the upgrade or try change the todayDate definition according to the code below.

    str         todayDate               = SysComputedColumn::comparisonLiteral(date2str(today(), 321, DateDay::Digits2,DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4,DateFlags::None));

  • syed baber Profile Picture
    11,633 on at

    Thanks a lot Dominic for your fast response. It did resolve the issue. I also found the hotfix for this issue, and the KB number is 2859489. Here is the Dynamics AX Life cycle services link:

    fix.lcs.dynamics.com/.../313591.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    please try to change the language of the SQL-user to "English". After this you need to restart the AOS-Service. this should solve the Problem if it was still existing.

    I expired this Problem still in AX2012R3CU9 in a German evironment.

    Daniel

  • Community Member Profile Picture
    on at

    Hello!

    We had the same problem and the solutions applied here have not helped. We do change the code of the computed column to german date format. The new code looks as follows:

    str todayDate = SysComputedColumn::comparisonLiteral(date2str(today(), 123, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4, DateFlags::None));

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans