Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamics AX 2009 - Programming Example

Posted on 2009-04-06
3
Medium Priority
?
1,102 Views
Last Modified: 2012-05-11
Dear Experts,

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

Table1
-------------
Id
Description
BeginDate
EndDate

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.
0
Comment
Question by:Marius0188
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
Agrippine earned 2000 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';
    ;
 
    ttsbegin;
 
    while select forupdate inventTableModule
        where   inventTableModule.ItemId    == itemId
            &&  inventTableModule.PriceDate == datenull()
    {
        inventTableModule.PriceDate = systemdateget() - 1;
        inventTableModule.update();
    }
 
    ttscommit;
}

Open in new window

0
 

Author Comment

by:Marius0188
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....
0
 
LVL 5

Expert Comment

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

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part II
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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