Question & Answer
Question
Can you please supply an example of the use of the settlementDate function to subtract 40 working days from the current date.
Cause
Project requirement.
Answer
The function does not contain any functionality to determine the current date.
The function does working day calculations - i.e. it ignores weekends and bank holidays. The function requires a file containing bank holiday definitions (as these vary by locale). If there are no bank holidays to apply then an empty text file may be referenced.
Given the current date the function can determine an offset from the current date. e.g.
calling:
settlementDate(20130925,-40,%%PROJECT/ROOT%%/empty.txt,yyyyMMdd)
yields:
20130731
Which is correct since 31/July/2013 is 40 working days prior to 25/Sept/2013. (I find it is easier to think in terms of 5 day working weeks - 40 days is 8 * 5 days, there are 5 days in a week, so these dates are 8 weeks apart.)
To retrieve the current date we can call now() passing the required date format, and hence our expression would become:
settlementDate(now(yyyyMMdd),-40,%%PROJECT/ROOT%%/empty.txt,yyyyMMdd)
Please be aware that doing this may make the test non-deterministic, so please use the now() function with care to ensure that the success or failure of your tests is not dependent on the current date (even if the execution of that test were to span midnight local time, should your testing sometimes run overnight).
If you wish to calculate a date based upon calendar days rather than working days then there is no need to use the settlementDate() function, and such a calculation cannot be done using settlementDate().
N.B. The above expressions are given using the IBM Rational Integration Tester (RIT) legacy syntax. This syntax can be used in RIT anywhere that an expression can be evaluated. Within the Function Action the alternate ECMAScript syntax may be used, so the expression would then become:
settlementDate( now("yyyyMMdd"), -40, tags["PROJECT/ROOT"]+"/empty.txt", "yyyyMMdd")
Was this topic helpful?
Document Information
Modified date:
11 July 2019
UID
swg21652057