Add/Subtract Dates using the Java Date Translator
**Note: This Feature Has Been Deprecated.
Please use this link to find alternative features:
The Java Date Translator is a very powerful tool, commonly used to determine the difference between two dates (Most date conversion can now be accomplished with a UDF). However, there is an often overlooked feature that has proved to be useful to a number of our clients, the “Add/Subtract” parameter. This parameter allows for the developer to create a logical date field based off of a difference of years, months or days. So, when would someone want to use this feature? Let’s say that we need to review all of the sales for the six previous months. Each salesman who has sold over a certain amount over this six month range will be awarded a bonus. We can even take the scenario one step further; say that this award is given out every month making it a rolling six month date range. Let’s see how this is accomplished.
In our example the goal is to create two date fields, one that will return today’s date and one to return a date six months prior. The first step is to create a calculation that calls the Java Date Translator to retrieve today’s date. I will create my calculation with the attributes of 8,0 in yyyymmdd format (you will be able to use any field attributes for the available Output/Input parameters).
Setting my calc to the Output/Input: 8.0 format (*YMD8 yyyymmdd) format.
Step 2 is to create a calculation with the attributes of 4,0 for the Add/Subtract function and set the value to the amount of months/days/years you would like added/subtracted from the current date (example: -6). All Java Date Translator parameters require a field of 4,0 for subtraction/addition.
Next we will need to create our final calculation. The attributes of this calculation should match your first calculation (in this case 8,0) and call the Java Date Translator object again. This time we’re going to utilize three parameters.
The first parameter is an input that calls our first calculation. Remember, CALCULA001 will retrieve today’s date.
The second parameter will utilize the ‘Input: Add/Subtract Month On Input Date’ parameter to subtract the number of months from CALCULA001.
For the last parameter we will call the current calculation. This will use the other parameters to compute and display the new desired date.
We are almost finished! From here, all we need to do is build and compile our application. When run, the application output will look something like the screen shot below. You can see that the application is correctly displaying columns for today’s date (calculation 1) and the new date (calculation 3) providing us with the desired 6 month date range.