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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AIF custom service TransDate field is rendering as date at 12 PM

(0) ShareShare
ReportReport
Posted on by 50

Hi,

I've posted this question to StackOverflow, but I figured I'd post it here as well. 

I have a bit of a mystery with a Dynamics AX 2012 R2 CU7 custom service. It's really simple and it basically assigns some data to a contract for a downstream system to use.

orderContract.shippingDateRequested(SalesTable.shippingDateRequested);

This contract field, for instance, is based on the TransDate EDT. When I look at the data in sql server, it's the date at midnight which is pretty standard.

My mystery is that when the data comes through the port ( c# console app and BizTalk 2013 R2 as consumers ), the date now comes through as date @ 12 PM. 

Am I missing something here or is this by design? Can I stop this behaviour and have it pass the time as 00:00:00 instead?  The downstream system is setup to assign that "date only" columns are set at 00:00:00.

*This post is locked for comments

I have the same question (0)
  • nunomaia Profile Picture
    25 Moderator on at

    You re printing the date to console using your regional settings or printing the UTC data time?

  • Suggested answer
    Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at

    You should realize that dates are not strings; they're converted to string only when needed and the same date may look completely differently for different users (depending on their date format in Windows, for example).

    Therefore it has nothing do with Dynamics AX; it's all about what format your console application uses. You can, for example, change Thread.CurrentCulture or explicitly convert dates to string using a custom format.

  • Richard K Profile Picture
    50 on at

    So, I completely realize that Dates are not strings.  

    The culture that I'm running under won't change the time on the output. In my C# test application, the object that's coming across is a System.DateTime type.

    Console.WriteLine(item.shippingDateRequested.Hour);

    That gives me 12 as an output.  So unless there's some funky System.DateTime stuff going on, it's 12 PM.

    I could see culture messing with me around the dates if I was doing the good ole mm/DD/yyyy or DD/mm/yyyy or yyyy-mm-dd.

  • Richard K Profile Picture
    50 on at

    I thought the regional settings were my issue, but I would have expected the time offset to be -7, not +12.

  • Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at

    I'm sorry, but your question wasn't clear to me. Your discussion about formats ("00:00:00" vs "@ 12 PM") gave me an impression that you want a different format; now it seems it's irrelevant (or marginal, at least); you're sying that you're actually getting an unexpected value.

    Please try converting your date with "o" format:

    Console.WriteLine("{0:o}", item.shippingDateRequested);

    It includes not only hours, but also timezone offset, which might give you some extra information. (Honestly I have no idea whether AX returns timezone in DateTime structures.)

    If you can, do some debugging to find out when the value changes. (You can debug CIL code in AX using Visual Studio.)

  • Richard K Profile Picture
    50 on at

    I ran the question I posted past a co-worker here and he thought my question was not clear either, so I'm sorry for that.

    Console.WriteLine(item.shippingDateRequested.ToString("zzz"));
    Console.WriteLine(item.shippingDateRequested.Kind.ToString());
    Console.WriteLine("{0:o}", item.shippingDateRequested);

    Ran that and got

    -07:00
    Unspecified
    2015-10-05T12:00:00.0000000

    So based on that, I'm still at a bit of a loss as to why I'm getting 12 PM.  I'll try the CIL debugging route to see what's going on. 

    Thanks for the help and ideas.

  • Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at

    I think it's worth checking the value just before returning it from AX and just after receiving it in your application. You'll either find out that the problem is in one of these applications (so you'll know what the debug), or that it somehow changes during serialization and transfer (and we'll start thinking about how it's possible).

  • Richard K Profile Picture
    50 on at

    So, I attached the debugger to see what's happening in CIL in the custom service.  In my method where I'm filling the contract from the SalesTable table buffer, I'm seeing this in the VS debugger:

    ShippingDateRequested	{Microsoft.Dynamics.Ax.Xpp.AxShared.Date}	Microsoft.Dynamics.Ax.Xpp.AxShared.Date
    DateValue	{7/13/2015 12:00:00 PM}	System.DateTime
    Value	{7/13/2015 12:00:00 AM}	System.DateTime

    It's looking like it's how the Microsoft.Dynamics.Ax.Xpp.AxShared.Date CIL type is handling the hour as it pushes through to a System.DateTime.

  • Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at

    I'll try it in my system (AX 2012 R3; don't have R2 CU7 on hand) and will let you know if I can reproduce it.

  • Verified answer
    Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at

    Yes, you're right - it behaves the same in my system. I think I've never noticed it because looking at time part of date-only field isn't very useful. (Nevertheless I completely understand that you may want to show the time part and expect it to be empty.)

    I don't have any explanation why it happens and it indeed looks wrong, therefore I suggest to report it to Microsoft.

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

News and Announcements

Season of Giving Solutions is Here!

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 2 Most Valuable Professional

#1
Nakul Profile Picture

Nakul 2

#3
Umar-Usman Profile Picture

Umar-Usman 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans