Dynamics AX 2009 - Programming Example

Posted on 2009-04-06
Last Modified: 2012-05-11
Dear Experts,

In AX 2009 can someone please assist me with the following code example:


Basically I need to run an update query that will find rows where id = x and EndDate = <empty> then update the row and insert EndDate = Date - 1 day.

What I am struggling with is date time methods in X++.
1. How can you subtract 1 day from a datetime value????
2. Query to update all rows where Id = X and EndDate = <empty>, how will this where clause looks like?

Please help ASAP.
Kind regards.
Question by:Marius0188
  • 2

Accepted Solution

Agrippine earned 500 total points
ID: 24084655
Hi again ;-)

to check for an empty date, use the method datenull().
To set a field to date - 1, just write "systemdateget() - 1" ...

I hope the example helps.

Kind regards!

static void Job1(Args _args)


    InventTableModule   inventTableModule;

    ItemId              itemId = 'ESB-007';



    while select forupdate inventTableModule

        where   inventTableModule.ItemId    == itemId

            &&  inventTableModule.PriceDate == datenull()


        inventTableModule.PriceDate = systemdateget() - 1;





Open in new window


Author Comment

ID: 24085034
Just another question.
Let say you instead of using systedateget() you would like to use the date field from a row?

Would you simple - 1 as well to get the day before?

Thanks for the quick reply....

Expert Comment

ID: 24085205
Yes, I would
inventTableModule.PriceDate = inventTableModule.PriceDate - 1;

Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to path 13 77
TFS - Rolling back to a previous release / CRM 2011 8 113
Create a Custom Case Entity In Dynamics CRM 2011 10 60
CRM 2011 Error when closing 17 71
This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now