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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Refactoring Date field to UtcDateTime field.

(0) ShareShare
ReportReport
Posted on by

**Quick Version**

Is there a clean / recommended way to amend an AX Date field to an AX UtcDateTime field?

**Long Version**

We recently ran the LifeCycle Services (LCS) Customisation Analysis tool on our model, and passed the results to our developers to correct.  A common warning was the use of non UTC date/time fields; i.e. "Field %1 of table %2 is not UTC compliant".

Since we've been using our code in production for a while now, there's data in the associated tables, so the developers are stating that they can't safely change the field to a UTC date.

My assumption would have been that you could simply change the type of the field to a UtcDateTime, and AX would keep the same data in the database's DateTime column, and create an entry in the DateTimeTZID (int) column with the default value (37001).  

That said, looking in the AOT I couldn't see a simple option for amending the type from Date to UtcDateTime, so I imagine it's more complex than I'd thought.  It would be possible to rename the date field prefixing with DEL_, create the new field with the correct name, then in SQL copy values from one to the other, but presumably all AX code would still refer to the DEL_ field internally (i.e. despite the rename, it would still have the same object id)?

As well as AX, we need to consider our BI solution.  They're less concerned by timezones (at present) / would be happy with the approximate datetime value ignoring the timezone component; so our only real concern there would be ensuring the field name didn't change.

Is there a clean / recommended way to amend an AX Date field to an AX UtcDateTime field?

Thanks in advance,

JB

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: Refactoring Date field to UtcDateTime field.

    Customization analysis is telling you that your solution likely won't work across time zones. If you're saying that you actually don't need (at present) to address this problem, what would be the point of the whole exercise?

    I would indeed use an extra field. You'll have to review your code and forms anyway, to make sure that they work with time zones correctly. For example, if you're reading a date value from database in code, you may need to add extra code to convert the UTC value to local time (in user's preferred time zone in most cases, but not always).

  • Community Member Profile Picture
    on at
    RE: Refactoring Date field to UtcDateTime field.

    Thanks Martin.  

    >...what would be the point of the whole exercise?

    Had there been an easy option for converting the type without too much development overhead it may have been worthwhile just to make things "correct"; our users are spread across 3 timezones, but all within a 2 hour timespan, so it's not ideal, but also not a big concern.

    >You'll have to review your code and forms anyway...

    Ah ok, this is definitely more complex than I'd anticipated; my assumption was that Date and UtcDateTime were the same aside from Date defaulted the timezone to UTC (i.e. didn't care about the timezone component, but held as if it were UTC) whilst UtcDateTime held the date as a UTC date but also had a defined timezone to allow it to be offset as required to get the time & timezone to which it applies (e.g. so any actions could be based around that timezone), with the display adjustment used user's userinfo.preferredtimezone to adjust that value for display.

    Thank-you again.

    JB

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans