/*********************************************************************************************/ /* Description: */ /* Description: Retrieve Date Calculation Command Processor */ /* Performs date calculation by adding and substracting a given */ /* of number of days from given date returning result dates in */ /* a specified format. Returns values between two dates in for */ /* Month, Days and Years. Also returns day of the week name and number */ /* */ /* Major Functions: */ /* Program is only referenced via the Retrieve Date Calculation (RTVDTECALC) control */ /* language (CL) command. Purpose is to return date values to a CL program of various */ /* date command functions based on given dates and requested parameters. */ /* */ /* Parameters: */ /* From date - Required date field. Command entry is *MDY format but command interface */ /* converts date format to command processor program in *CYMD format. */ /* To date - Optional date field. Command entry is *MDY format but command interface */ /* converts date format to command processor program in *CYMD format. */ /* #Days - Optional numeric field indicating how many days to add and subtract from the*/ /* From date. */ /* #Months - Optional numeric field indicating how many months to add and subtract from */ /* the From date. */ /* #Years - Optional numeric field indicating how many years to add and subtract from */ /* the From date. */ /* Plus date - Return character field indicating the result date in *MDY format after */ /* adding the days, months or years to the From date. */ /* Minus date- Return character field indicating the result date in *MDY format after */ /* subtracting the number of days, months or years from the From date. */ /* Days - Return numeric field indicating the number of days between the From and */ /* To dates. */ /* Months - Return numeric field indicating the number of months between the From and */ /* To dates. */ /* Years - Return numeric field indicating the number of years between the From and */ /* To dates. */ /* DayofWk - Return character field indicating the day of the week of the From date. */ /* e.g., Sunday, Monday....Friday, Saturday. */ /* DayofWk# - Return numeric field indicating the day of the week of the From date. */ /* e.g., 0=Sun, 1=Mon....5=Fri, 6=Sat. */ /* */ /* Recovery/Re-run: */ /* Not applicable */ /* Special Compile options: */ /* Allowed environments: *IPGM *BPGM *IREXX *BREXX *IMOD *BMOD */ /* Command Processing program: RTVDTECALC */ /*********************************************************************************************/ RTVDTECALC: CMD PROMPT('Retrieve Date Calculations') PARM KWD(FROMDATE) TYPE(*DATE) MIN(1) + CHOICE('MMDDYY, M/D/Y format') + PROMPT('From or single date') PARM KWD(TODATE) TYPE(*DATE) CHOICE('MMDDYY, + M/D/Y format') PROMPT('To date (optional)') PARM KWD(#DAYS) TYPE(*DEC) LEN(3) DFT(0) RANGE(0 + 400) PROMPT('Days to add & subtract') PARM KWD(#MONTHS) TYPE(*DEC) LEN(2) DFT(0) + RANGE(0 48) PROMPT('Months to add & + subtract') PARM KWD(#YEARS) TYPE(*DEC) LEN(2) DFT(0) RANGE(0 + 30) PROMPT('Years to add & subtract') PARM KWD(PLUSDATE) TYPE(*CHAR) LEN(6) + RTNVAL(*YES) PROMPT('From_Date plus in + MDY (6)') PARM KWD(MINUSDATE) TYPE(*CHAR) LEN(6) + RTNVAL(*YES) PROMPT('From_Date minus in + MDY (6)') PARM KWD(DAYS) TYPE(*DEC) LEN(4) RTNVAL(*YES) + PROMPT('Days between given dates (4)') PARM KWD(MONTHS) TYPE(*DEC) LEN(4) RTNVAL(*YES) + PROMPT('Months between given dates (4)') PARM KWD(YEARS) TYPE(*DEC) LEN(4) RTNVAL(*YES) + PROMPT('Years between given dates (4)') PARM KWD(DAYOFWKNAM) TYPE(*CHAR) LEN(9) + RTNVAL(*YES) CHOICE('Character + (Sunday...Saturday)') PROMPT('Day of the + week name (9)') PARM KWD(DAYOFWKNUM) TYPE(*DEC) LEN(1) + RTNVAL(*YES) CHOICE('Number + (0=Sun...6=Sat)') PROMPT('Day of the week + number (1)') DEP CTL(PLUSDATE) PARM((&#DAYS *NE 0) (&#MONTHS + *NE 0) (&#YEARS *NE 0)) NBRTRUE(*EQ 1) /* + If Todate, at least 1 value */ DEP CTL(MINUSDATE) PARM((&#DAYS *NE 0) (&#MONTHS + *NE 0) (&#YEARS *NE 0)) NBRTRUE(*EQ 1) /* + If Todate, at least 1 value */ DEP CTL(#DAYS) PARM((#MONTHS) (#YEARS)) + NBRTRUE(*NE 1) DEP CTL(DAYS) PARM((TODATE)) DEP CTL(MONTHS) PARM((TODATE)) DEP CTL(YEARS) PARM((TODATE))