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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans