Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 3 Tools : $ADD_DATE

$ADD_DATE
Adds or subtracts a component (such as a day, week, month, or year) to or from a date and returns a new date value. (F)
Invocation
new_date = $ADD_DATE(date, component, amount)
 
Its syntax is C (fixed-length character string) with a length of one.
Usage Notes
If the component being added or subtracted is a month, $ADD_DATE returns the last possible date in the resultant month if the resultant day does not exist in the resultant month. For example, one month subtracted from MARCH 31, 2000 returns a value of FEBRUARY 29, 2000.
Treat with caution values returned for dates prior to the adoption of the Gregorian calendar in 1582 or for dates in the very far future that could be subject to calendar adjustments (for example, it is not yet clear if the year 4000 is a leap year). $ADD_DATE accurately returns values for dates 200 years before or after the present date.
See Also
TIBCO Object Service Broker for z/OS Installing and Operating for information on YYCENTURYRANGE in z/OS. See TIBCO Object Service Broker Parameters for information on YYCENTURYRANGE in Open Systems.

Exceptions
 
Signaled if date is not a valid date or if the value given for amount is not a number.
Signaled if the value given for component is not one of D, W, M, or Y.
Example
The following rule returns the employee names and the dates when they reach their five-year anniversaries, and displays the result in the message log:

 
ADD_DATE;
_ LOCAL ANNIV_DATE;
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ CALL MSGLOG('THE ANNIVERSARY DATES FOR THE EMPLOYEES ARE') | 1
_ ; |
_ FORALL EMPLOYEE_DATE WHERE HIREDATE >= $CREATE_DATE( | 2
_ 'YYYY/MM/DD', '1997/04/01') : |
_ ANNIV_DATE = $ADD_DATE(EMPLOYEE_DATE.HIREDATE, 'Y', 5); |
_ CALL MSGLOG(PAD(EMPLOYEE_DATE.LNAME, 22, ' ', 'L') |
_ || ANNIV_DATE); |
_ END; |
_ ---------------------------------------------------------------------------

 
Pressing PF2 after executing the rule displays the following screen:

 
---------------------------- INFORMATION LOG ----------------------
COMMAND ===> SCROLL: P
THE ANNIVERSARY DATES FOR THE EMPLOYEES ARE
SMYTHE 2003-09-18
CHANG 2003-04-05
GARZA 2002-06-30
TOWNSEND 2002-05-13
.

 

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved