web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans