Advance Work Days BSFN, AdvanceDate API, backwards

szNick

Member
I have a requirement to use the Work Days Calendar (F0007) information in reverse. For example, if today is 9/10/2018 and the user inputs '-1', I'd like to call B0000150 - Advance Work Days with the parameter mnDaysToAdd = -1. It would return 9/7/18 (the previous work day).

Right now when I make this call it hangs indefinitely. In the C Code, it loops here (mnDaysToAdd is the parameter passed in to B0000150):

Code:
while ( MathCompare ( &mnDaysAdded, &mnDaysToAdd ) != 0 )
	{
		AdvanceDate (&jdAdvancedDate, lpjdDateToAvance, 0, 1 );
                     .
                     [i] logic [/i]
                     .
                IncrementMathNumeric ( &mnDaysAdded, 1 );
        }

Obviously if mnDaysToAdd is negative and the counter increments, they will never equal each other and the loop is infinite.

In attempting to fix this, I noticed that passing -1 into 'AdvanceDate' also does not fix this. It increments the date regardless (i.e.: 9/10/18 becomes 9/11/18).

My question is, what would be the best course of action here? Is the JDE API AdvanceDate not capable of choosing a previous Work Calendar day? Is there a function that does let me use a calendar from F0007 to do this? Any help appreciated.
 
Top