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


Chapter 3 Tools : $DATE_REF

$DATE_REF
Adds or subtracts a given number of days to or from a reference date, and converts the number of days returned to units of a day, a week, a month, or a year. (F)
Invocation
value = $DATE_REF(component, duration, date, round)
 
Its syntax is C (fixed-length character string), with length 1.
An integer specifying the number of days to be added or subtracted. Its syntax is B (binary) with length 4.
Usage Notes
One‑ or two‑digit week # (of year), with no leading 0.
Two‑digit week # (of year).
Two‑character quarter.
Two‑digit century.
/ \ ; : , . * - blank
A week is defined to begin on a Monday and end on the following Sunday. However, January 1st always begins week one, regardless of where it falls in the week, and week two starts on the following Monday.
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). $DATE_REF accurately returns values for dates 200 years before or after the present date.
See TIBCO Object Service Broker for z/OS Installing and Operating for information on YYCENTURYRANGE. See TIBCO Object Service Broker Parameters for information on YYCENTURYRANGE in Open Systems.
You can specify just a portion of a date field within your mask (for example, entering only MMMM displays the month). Partial date occurrences cannot be accessed using a GET or FORALL statement, as the data cannot be interpreted as a complete date. At least the year portion of a date must be present in the mask to make it accessible to these statements.

Exceptions
 
Signalled if component is not a number or if date is not a date.
Signalled if the value given for component is not one of D, W, M, or Y, or if the value given for duration is not valid for component.
Example
The following rule references the date 98/05/03, subtracts 100 days from it, and returns the number of months, truncated to the nearest month. It displays the result on the message line of the workbench.

 
DATE_REF;
_
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ CALL ENDMSG('-100 DAYS IS ' || $DATE_REF('M', - 100, | 1
_ $CREATE_DATE('YY/MM/DD', '98/05/03'), 'N') || |
_ ' MONTHS FROM THE REFERENCE DATE'); |
_ ---------------------------------------------------------------------------

 
It returns:
-100 DAYS is -3 MONTHS FROM THE REFERENCE DATE

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