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)
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Problem with subtracting field value from today( ) in SELECT statement where clause

Posted on by
Hi,
 
I am having an issue with trying to subtract from the today( ) in the where clause of a SELECT statement. 
 
I am using the SalesLine to get the warehouse in InventDim, which is then used to get the number of days in the past in a custom table.  This number of days is used to subtract from today's date to determine whether to process or not. It is of type Integer, has no EDT, and has the value 14.
 
The sample code is below, and if I substitute the field for the number of days in the past by hardcoding, it works.  Are you not allowed to subtract a integer field value from today( )? 
 
Thanks in advance!
 
    SalesLine           salesLine;    
    InventDim           inventDim;
    myCustomParmTable   customParmTable; // has two fields: InventLocationId, NumDaysInPast (type Integer; value = 14)     
    
    SalesId         _salesId = 'SO-00001001';     
    ;       
    while select salesLine 
        where salesLine.SalesId == _salesId
        join inventDim  
            where inventDim.inventDimId == salesLine.InventDimId
                join customParmTable
                    where customParmTable.InventLocationId == inventDim.InventLocationId &&
                          salesLine.ConfirmedDlv >= today() - 14                                 // <-- this goes in loop  
 //                       salesLine.ConfirmedDlv >= today() - customParmTable.NumDaysInPast      // <-- this doesn't go in loop           
    {
        // process SO line
        info("Inside while loop");  
    }

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