The ADDDAT command allows you to add or subtract a number of days
from a specified date. The new date is passed back in a return
value. The command is useful for determining expiration dates or any
other form of scheduling.
A typical use of the command would appear as:
ADDDAT DAYS(14) TOVAR(&NEWDAT)
This command will add 14 days to the current date and return the new
date in the &NEWDAT variable.
The DAYS parameter can be negative in which case you can determine a
date in the past (e.g. what is the date that is 90 days in the
past).
ADDDAT handles the conversion to the next month, next year, leap
year, etc. The command can only be used in a CL program.
Date range
----------
ADDDAT uses the TAA Tool CVTDAT2 to convert dates. This avoids the
restriction of the system CVTDAT command which has a range of 1940 to
2039, or 1928 to 1971 depending on the format used.
CVTDAT2 has a restriction of years 1600 to 4000. Since only a 6
digit date can be entered on ADDDAT and 80,000 days maximum added (or
subtracted), the actual range of ADDDAT is about 1720 to 2259.
ADDDAT Command parameters *CMD
-------------------------
DAYS The number of days to add or subtract from the DATE
parameter. For subtraction, enter a minus number.
A range of -80000 to +80000 is supported.
TOVAR The return variable for the new date. It must be
defined as *CHAR LEN(6). No separators will be
included. The format of the return variable is
controlled by the TOVARFMT parameter. The 6
character return variable can only be used with date
formats that produce 6 character dates. Use TOVAR
when the TOVARFMT parameter is one of the following
- *JOB, *SYSVAL, *MDY, *DMY, *YMD, or *JUL.
DATE The date to add or subtract from. The default is
*TODAY meaning the current date (the system value
QDATE is used and not the job date). If *TODAY is
entered, the system value format is used and
overrides any value entered for DATEFMT.
If a specific date is entered, it must be in the
format as described by the DATEFMT parameter.
The special value *JOB may be entered to provide the
job date. The value *TODAY causes the retrieval of
the system value QDATE and will change at midnight
even though the job was started before midnight.
The job date is initialized from the system value
when the job is started and will not change at
midnight. The CHGJOB command can also set the job
date.
TOVARFMT The format of the TOVAR return value. The default
is *JOB. The other values which may be entered are
*MDY, *YMD, *DMY, *JUL, *SYSVAL, *CYMD, *MDYY,
*DMYY, *YYMD, *ISO, *USA, *EUR, *JIS, or *LONGJUL.
DATEFMT The format of the DATE parameter. The default is
*JOB. The other values which may be entered are
*MDY, *YMD, *DMY, *JUL, and *SYSVAL.
See the ADDDAT2 command if a date format which uses
a 4 digit year (such as *YYMD) is required.
TOVAR2 The return variable for the new date in 10
characters. It must be defined as *CHAR LEN(10).
The format of the return variable is controlled by
the TOVARFMT parameter. The 10 character return
variable can be used with any date format.
The return variable for TOVAR2 must be declared as
10 characters, but the value placed in the variable
will vary in length. The value is always left
adjusted.
The format *JUL returns a 5 character value with no
separators.
The formats *JOB, *SYSVAL, *MDY, *DMY, *YMD return 6
character values with no separators.
The format *CYMD returns a 7 character value
(CYYMMDD) with no separators.
The formats *MDYY, *DMYY, and *YYMD return an 8
character value with no separators.
The formats *ISO, *USA, *EUR, and *JIS return 10
character values that always include the standard
separator values.
Using ADDDAT without adopting authority
---------------------------------------
A second program TAADATAC2 exists that can be called which is
specified as USEADPAUT(*NO). This allows a program that adopts
authority to use the basic ADDDAT function without security concerns.
Only the following parameters are supported:
DAYS It must be passed as *DEC LEN(5 0)
NEWDAT It must be passed as *CHAR LEN(6)
DATE It must be passed as *CHAR LEN(6). Note that this
value is placed in the DATE parameter of ADDDAT
which is declared as *DEC LEN(6 0). By passing the
value as *CHAR, you can specify *TODAY or a date.
The CALL should be made as:
CALL PGM(TAATOOL/TAADATAC2) +
PARM(&DAYS &NEWDAT &DATE)
Restrictions
------------
** See previous comments about valid date ranges.
** Only valid dates may be entered.
Prerequisites
-------------
The following TAA Tools must be on your system:
CVTDAT2 Convert date 2
Implementation
--------------
None, the tool is ready to use:
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ----- --------- ---------- -----------
ADDDAT *CMD TAADATA QATTCMD
TAADATAC *PGM CLP TAADATAC QATTCL
TAADATAC2 *PGM CLP TAADATAC2 QATTCL
|