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)

UTCDateTime

(0) ShareShare
ReportReport
Posted on by

Hi all,

I don't know why I am struggling with this but I want to get all sales orders for today through x++ code.

So I want something like this:

while select salesTable where salesTable.createdDateTime == today()

does not work, I've tried UTCDateTime functions as well but I can't seem to get it.

while select salesTable where salesTable.createdDateTime == DateTimeUtil::date(DateTimeUtil::utcNow())

I don't care about the time, I simply want to loop through all records that were created today() or systemDateGet()


Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Community member Profile Picture
    85 on at

    I believe you problem is that when you are doing == the createdDateTime is UTC and has a specific time and so does your DateTimeUtil::utcNow(), so the times will mis mastch.  Perhaps you should think about the following pseudo code: "where salesTable.createdDateTime >= "min todays time" && salesTable.createdDateTime <= "min todays time"

  • Verified answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    Because you should have no orders "created in future", you can simply call:

    where salesTable.createdDateTime > DateTimeUtil::newDateTime(
        systemDateGet(), 0, DateTimeUtil::getUserPreferredTimeZone());
  • Suggested answer
    Community Member Profile Picture
    on at

    Thank you Martin.  Exactly what I was looking for.

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