MOD_DATE

Figure 1. MOD_DATE syntax - with template

1  MOD_DATE ( fieldname  , mask?  , day?  , month?  , year(1)
Notes:
  • 1 At least one of these parameters (day, month, year) must be specified.
Figure 2. MOD_DATE syntax - without template

1  MOD_DATE ( start  , length  , type  , mask?  , day?  , month?  , year(1)
Notes:
  • 1 At least one of these parameters (day, month, year) must be specified.

(Can be used in FASTREXX procedures.)

Note:
  1. Only modifies valid dates. Input and modified dates must range between and include 15 October 1582 to 31 December 9999.
  2. Commas following the last specified argument can be omitted.

MOD_DATE can be run with or without a template and enables you to set, increment, or decrement a date field using year.month and day values. The fieldname or location parameters (start, length, type), the mask parameter and at least one of the year or month or day values must be specified for the function call to be valid. The input value is taken from the current output buffer and the modified value is stored in the output buffer.

fieldname
A template is required with this form and the name you specify must match a field name in the template. For non-unique names, you can specify a name in the form groupname.dataname. Name matching is not case-sensitive. If the name is unqualified, then the first occurrence of the name is used. For dimensioned fields, you can refer to an individual array element by providing a suffix subscript in the form (nn), where nn is a valid subscript for the dimensioned field. If you do not provide a subscript, the function applies to all elements of the array.
Note:
  1. If you are running a copy process and you have specified an input and output template, then the field name must be defined to both input and output templates.
  2. If you are copying multiple record layouts, the MOD_DATE function applies to records that have been identified as the record layout which contains this field.
start
Position, in bytes, in the input record at which to start reading the field value. Can be specified as:
Absolute position
Must be a positive integer. Default value is 1. If start is greater than the current length of the input record, the function has no effect.
Relative to current INPOS
Can be specified as IPx or INx, or as Px or Nx. If this resolves to a value of less than or equal to zero or greater than the current length of the input record, the function has no effect.
Relative to current OUTPOS
Must be specified as OPx or ONx. If this resolves to a value of less than or equal to zero or greater than the current length of the input record, the function has no effect.
length
The length of the field in bytes.

For binary fields, either omit the length or specify 4.

For packed decimal fields, if you specify the length, it must be in the range 1–16. If you omit the length, MOD_DATE attempts to determine the packed field length from the record data and returns only that field.

type
The data type of the field. Valid values are:
B
Binary.
C
Character. This is the default.
P
Packed decimal.
mask
Picture string describing the date. File Manager supports all pictures described in the z/OS® Language Environment® Programming Services, Appendix B, "Date and time services tables". In addition to those masks, File Manager supports CYYDDD to handle old century value Julian dates. A "C" value of "0" is interpreted as "19", and a "C" value of "1" is interpreted as "20". By default, 2-digit years lie within the 100-year range starting 80 years prior to the system date covered by the LE masks. The default range is changed by specifying the century parameter.
Note: If date and time attributes are defined in the template for fieldname the mask parameter can be omitted. File Manager uses the internal date format defined in the template.
day
Day adjustment.
month
Month adjustment.
year
Year adjustment.

The day, month, and year adjustment values can set, increment, and or decrement the respective value in the date field. The presence of a plus or minus symbol indicates the number provided is to increment or decrement the current value. The absence of plus or minus symbols indicates the number is to replace the current value. If the first non-blank character is an asterisk, then the current day, month, or year value is used to set the current value, otherwise it is derived from the record. For the month value or year value, you can suffix the value with an "E" to indicate end of month adjustment. If the input date is the end of month, then the resultant date is the end of month, unless day arithmetic is also performed.

Here are examples showing how to code them:
'*+10'
Sets the current day, month, or year and adds 10 to it.
'*-10'
Sets the current day, month, or year and subtracts 10 from it.
'+10'
Adds 10 to the current value found on the record.
'-10'
Subtracts 10 from the current value found on the record.
'+3E'
Adds 3 months and make adjustments for end of month if required.
'22'
Sets the respective day, month, or year value to 22.
Note: If you specify the symbols "*", "+", or "-", you must code the value in quotation marks.

Month and Year Arithmetic:

If input date is the last day of the month and you specify "E" as the suffix on the month or year value, or if the resulting month has fewer days than the day component of the input date, the result is the last day of the resulting month. Otherwise, the result has the same day component as input date.

Here are some examples:
  • Assume today is January 31, 2007. Adding one month results in the end of February, 2007-02-28.
  • "+3E" is specified for month, and the input date is February 28th 2007. The result is May 31st 2007.
  • "+3" is specified for month, and the input date is February 28th 2007. The result is May 28th 2007.
century
Specify a value between 0 and 100 to be used to define the 100-year range to interpret a 2-digit year. The default value is 80 years prior to the system date. Use this parameter to adjust that value.
error_report
Specify "Y" if you want to produce error messages when the function cannot modify a date because either the input or resultant date is invalid. The default is to ignore such dates.
tally_literal
Specify a literal to appear on a tally report that counts every successful operation of the function.

Examples

This COBOL copybook describes an input record with different date formats and is used here to illustrate MOD_DATE usage with a template or copybook.
01 DATE-REC.
   03 DATE-YYYYMMDD              pic x(8).
   03 DATE-MM-DD-YYYY            pic x(10).
   03 DATE-DD-MM-YYYY            pic x(10).
   03 DATE-YYYYDDD               pic x(7).
   03 DATE-YYYYDDDp              pic 9(7) packed-decimal.
   03 DATE-YYYYMMDDb             pic 9(8) binary.
   03 DATE-CYYDDD                pic 9(6) packed-decimal.
   03 DATE-DDMMYYYY              pic 9(8).
   03 DATE-YYMMDD OCCURS 6 times pic 9(6) packed-decimal.
   03 filler                     pic x.
   

Example 1

Add 60 days to all date fields and report any errors. Note all array fields are modified.

$$FILEM DSC INPUT=DDIN,
$$FILEM IGNLEN=YES,
$$FILEM TCIN=hlq.COBOL(SAMPLE),
$$FILEM OUTPUT=DDOUT,PROC=*
MOD_DATE('DATE-YYYYMMDD','YYYYMMDD','+60',,,,Y)
MOD_DATE('DATE-YYYYMMDDB','YYYYMMDD','+60',,,,Y)
MOD_DATE('DATE-MM-DD-YYYY','MM/DD/YYYY','+60',,,,Y)
MOD_DATE('DATE-DD-MM-YYYY','DD/MM/YYYY','+60',,,,Y)
MOD_DATE('DATE-YYYYDDD','YYYYDDD','+60',,,,Y)
MOD_DATE('DATE-YYYYDDDP','YYYYDDD','+60',,,,Y)
MOD_DATE('DATE-CYYDDD','CYYDDD','+60',,,,Y)
MOD_DATE('DATE-DDMMYYYY','DDMMYYYY','+60',,,,Y)
MOD_DATE('DATE-YYMMDD','YYMMDD','+60',,,,Y)
/*

Example 2

Same as example 1 without using a copybook.

$$FILEM DSC INPUT=DDIN,
$$FILEM OUTPUT=DDOUT,PROC=*
MOD_DATE(1,8,C,'YYYYMMDD','+60',,,,Y)
MOD_DATE(40,4,B,'YYYYMMDD','+60',,,,Y)
MOD_DATE(9,10,C,'MM/DD/YYYY','+60',,,,Y)
MOD_DATE(19,10,C,'DD/MM/YYYY','+60',,,,Y)
MOD_DATE(29,7,C,'YYYYDDD','+60',,,,Y)
MOD_DATE(36,,P,'YYYYDDD','+60',,,,Y)
MOD_DATE(44,,P,'CYYDDD','+60',,,,Y)
MOD_DATE(48,8,C,'DDMMYYYY','+60',,,,Y)
MOD_DATE(56,,P,'YYMMDD','+60',,,,Y)
MOD_DATE(60,,P,'YYMMDD','+60',,,,Y)
MOD_DATE(64,,P,'YYMMDD','+60',,,,Y)
MOD_DATE(68,,P,'YYMMDD','+60',,,,Y)
MOD_DATE(72,,P,'YYMMDD','+60',,,,Y)
MOD_DATE(76,,P,'YYMMDD','+60',,,,Y)
/*

Example 3

Add 2 months and 20 days to all date fields and ignore errors.

$$FILEM DSC INPUT=DDIN,
$$FILEM IGNLEN=YES,
$$FILEM TCIN=hlq.COBOL(SAMPLE),
$$FILEM OUTPUT=DDOUT,PROC=*
MOD_DATE('DATE-YYYYMMDD','YYYYMMDD','+20','+2')
MOD_DATE('DATE-YYYYMMDDB','YYYYMMDD','+20','+2')
MOD_DATE('DATE-MM-DD-YYYY','MM/DD/YYYY','+20','+2')
MOD_DATE('DATE-DD-MM-YYYY','DD/MM/YYYY','+20','+2')
MOD_DATE('DATE-YYYYDDD','YYYYDDD','+20','+2')
MOD_DATE('DATE-YYYYDDDP','YYYYDDD','+20','+2')
MOD_DATE('DATE-CYYDDD','CYYDDD','+20','+2')
MOD_DATE('DATE-DDMMYYYY','DDMMYYYY','+20','+2')
MOD_DATE('DATE-YYMMDD','YYMMDD','+20','+2')
/*

Example 4

Set all date field values to the current date plus 1 for year, month, and date. Change the century window used for DATE-YYMMDD field to 60.

$$FILEM DSC INPUT=DDIN,
$$FILEM IGNLEN=YES,
$$FILEM TCIN=hlq.COBOL(SAMPLE),
$$FILEM OUTPUT=DDOUT,PROC=*
MOD_DATE('DATE-YYYYMMDD','YYYYMMDD','*+1','*+1','*+1')
MOD_DATE('DATE-YYYYMMDDB','YYYYMMDD','*+1','*+1','*+1')
MOD_DATE('DATE-MM-DD-YYYY','MM/DD/YYYY','*+1','*+1','*+1')
MOD_DATE('DATE-DD-MM-YYYY','DD/MM/YYYY','*+1','*+1','*+1')
MOD_DATE('DATE-YYYYDDD','YYYYDDD','*+1','*+1','*+1')
MOD_DATE('DATE-YYYYDDDP','YYYYDDD','*+1','*+1','*+1')
MOD_DATE('DATE-CYYDDD','CYYDDD','*+1','*+1','*+1')
MOD_DATE('DATE-DDMMYYYY','DDMMYYYY','*+1','*+1','*+1')
MOD_DATE('DATE-YYMMDD','YYMMDD','*+1','*+1','*+1','60')
/*